Skip to content

Commit

Permalink
Fix anext use for python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalkrupinski committed May 20, 2024
1 parent ffa0458 commit 0de562f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions httpx_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from httpx_auth._authentication import (
Basic,
HeaderApiKey,
MultiAuth,
QueryApiKey,
SupportMultiAuth,
)
Expand Down Expand Up @@ -63,6 +64,7 @@
"OAuth2ResourceOwnerPasswordCredentials",
"OktaResourceOwnerPasswordCredentials",
"WakaTimeAuthorizationCode",
"MultiAuth",
"SupportMultiAuth",
"JsonTokenFileCache",
"TokenMemoryCache",
Expand Down
34 changes: 17 additions & 17 deletions httpx_auth/_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import httpx


class _MultiAuth(httpx.Auth):
class MultiAuth(httpx.Auth):
"""Authentication using multiple authentication methods."""

def __init__(self, *authentication_modes):
Expand All @@ -16,29 +16,29 @@ def auth_flow(
next(authentication_mode.auth_flow(request))
yield request

def __add__(self, other) -> "_MultiAuth":
if isinstance(other, _MultiAuth):
return _MultiAuth(*self.authentication_modes, *other.authentication_modes)
return _MultiAuth(*self.authentication_modes, other)
def __add__(self, other) -> "MultiAuth":
if isinstance(other, MultiAuth):
return MultiAuth(*self.authentication_modes, *other.authentication_modes)
return MultiAuth(*self.authentication_modes, other)

def __and__(self, other) -> "_MultiAuth":
if isinstance(other, _MultiAuth):
return _MultiAuth(*self.authentication_modes, *other.authentication_modes)
return _MultiAuth(*self.authentication_modes, other)
def __and__(self, other) -> "MultiAuth":
if isinstance(other, MultiAuth):
return MultiAuth(*self.authentication_modes, *other.authentication_modes)
return MultiAuth(*self.authentication_modes, other)


class SupportMultiAuth:
"""Inherit from this class to be able to use your class with httpx_auth provided authentication classes."""

def __add__(self, other) -> _MultiAuth:
if isinstance(other, _MultiAuth):
return _MultiAuth(self, *other.authentication_modes)
return _MultiAuth(self, other)
def __add__(self, other) -> MultiAuth:
if isinstance(other, MultiAuth):
return MultiAuth(self, *other.authentication_modes)
return MultiAuth(self, other)

def __and__(self, other) -> _MultiAuth:
if isinstance(other, _MultiAuth):
return _MultiAuth(self, *other.authentication_modes)
return _MultiAuth(self, other)
def __and__(self, other) -> MultiAuth:
if isinstance(other, MultiAuth):
return MultiAuth(self, *other.authentication_modes)
return MultiAuth(self, other)


class HeaderApiKey(httpx.Auth, SupportMultiAuth):
Expand Down

0 comments on commit 0de562f

Please sign in to comment.