diff --git a/authx/_internal/_callback.py b/authx/_internal/_callback.py index 704818fa..049c8b3e 100644 --- a/authx/_internal/_callback.py +++ b/authx/_internal/_callback.py @@ -11,8 +11,7 @@ class _CallbackHandler(Generic[T]): - """ - Base class for callback handlers in AuthX. + """Base class for callback handlers in AuthX. Args: Generic (T): Model type diff --git a/authx/_internal/_memory.py b/authx/_internal/_memory.py index ba55ef18..da499d52 100644 --- a/authx/_internal/_memory.py +++ b/authx/_internal/_memory.py @@ -12,8 +12,7 @@ class MemoryIO: """ def __init__(self) -> None: - """ - Initialize an instance of MemoryIO. + """Initialize an instance of MemoryIO. Creates a dictionary to store the session data. """ diff --git a/authx/_internal/_signature.py b/authx/_internal/_signature.py index f1a73cc2..e4140bc4 100644 --- a/authx/_internal/_signature.py +++ b/authx/_internal/_signature.py @@ -6,14 +6,10 @@ class SignatureSerializer: - """ - A class that implements a URL-safe timed serializer. - """ + """A class that implements a URL-safe timed serializer.""" def __init__(self, secret_key: str, expired_in: int = 0) -> None: - """ - Initialize the serializer with a secret key and an optional expiration time. - """ + """Initialize the serializer with a secret key and an optional expiration time.""" self.ser = URLSafeTimedSerializer(secret_key) self.expired_in = expired_in diff --git a/authx/config.py b/authx/config.py index 1da8eec1..a9fefe16 100644 --- a/authx/config.py +++ b/authx/config.py @@ -1,5 +1,6 @@ +from collections.abc import Sequence from datetime import timedelta -from typing import List, Optional, Sequence +from typing import List, Optional from jwt.algorithms import get_default_algorithms, requires_cryptography from pydantic import Field diff --git a/authx/main.py b/authx/main.py index 728fa075..26e57359 100644 --- a/authx/main.py +++ b/authx/main.py @@ -1,10 +1,9 @@ import contextlib import datetime +from collections.abc import Awaitable, Coroutine from typing import ( Any, - Awaitable, Callable, - Coroutine, Dict, Literal, Optional, diff --git a/authx/schema.py b/authx/schema.py index d671f7eb..6b7448dc 100644 --- a/authx/schema.py +++ b/authx/schema.py @@ -1,7 +1,8 @@ import datetime import sys +from collections.abc import Sequence from hmac import compare_digest -from typing import Any, Dict, List, Optional, Sequence, Union +from typing import Any, Dict, List, Optional, Union from pydantic import BaseModel, Field, ValidationError from pydantic.version import VERSION as PYDANTIC_VERSION @@ -9,7 +10,7 @@ if sys.version_info >= (3, 8): # pragma: no cover from typing import Set # pragma: no cover else: - from typing_extensions import Set # pragma: no cover + from typing import Set # pragma: no cover from authx._internal._utils import get_now, get_now_ts, get_uuid from authx.exceptions import ( diff --git a/authx/token.py b/authx/token.py index b9da0215..655e2694 100644 --- a/authx/token.py +++ b/authx/token.py @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, List, Optional, Sequence, Union +from collections.abc import Sequence +from typing import Any, Dict, List, Optional, Union import jwt diff --git a/authx/types.py b/authx/types.py index 9a29b91e..c74d4985 100644 --- a/authx/types.py +++ b/authx/types.py @@ -1,6 +1,7 @@ import datetime import sys -from typing import Callable, Literal, Optional, Sequence, TypeVar, Union +from collections.abc import Sequence +from typing import Callable, Literal, Optional, TypeVar, Union if sys.version_info >= (3, 10): # pragma: no cover from typing import ParamSpecKwargs # pragma: no cover diff --git a/tests/app/conftest.py b/tests/app/conftest.py index 10f63267..2702c6e2 100644 --- a/tests/app/conftest.py +++ b/tests/app/conftest.py @@ -18,7 +18,6 @@ @pytest.fixture(scope="function") def config(): """Fixture for AuthX Configuration""" - return AuthXConfig( JWT_SECRET_KEY="secret", JWT_TOKEN_LOCATION=["headers", "json", "query", "cookies"], @@ -28,7 +27,6 @@ def config(): @pytest.fixture(scope="function") def api(config: AuthXConfig): """Fixture for FastAPI TestClient""" - app, security = init_app(config=config) create_protected_routes(app, security) create_token_routes(app, security) diff --git a/tests/test_core.py b/tests/test_core.py index 139f7665..6223ce6b 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,5 +1,6 @@ import json -from typing import Any, Coroutine, Dict, List +from collections.abc import Coroutine +from typing import Any, Dict, List import pytest from fastapi import Request diff --git a/tests/utils.py b/tests/utils.py index ee869c7e..859ac67f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -20,7 +20,6 @@ class SecuritiesTuple(NamedTuple): def init_app(config: Optional[AuthXConfig] = None) -> "tuple[FastAPI, AuthX]": """Initialize FastAPI app and AuthX instance.""" - app = FastAPI() security = AuthX(config=(config or AuthXConfig())) @@ -29,7 +28,6 @@ def init_app(config: Optional[AuthXConfig] = None) -> "tuple[FastAPI, AuthX]": def create_securities(security: AuthX) -> SecuritiesTuple: """Create a named tuple with all AuthX dependencies.""" - return SecuritiesTuple( access_token_headers=Depends( security.token_required( @@ -170,7 +168,6 @@ async def _protected_fresh_route(): def create_blocklist_routes(app: FastAPI, security: AuthX) -> None: """Create routes to test AuthX dependencies.""" - BLOCKLIST = set() @security.set_callback_token_blocklist @@ -195,7 +192,6 @@ async def _blocklist_access_route( def create_subject_routes(app: FastAPI, security: AuthX) -> None: """Create routes to test AuthX dependencies.""" - USER_DB = { "test": {"uid": "test", "email": "test@test.com"}, "foo": {"uid": "foo", "email": "foo@bar.com"},