From e7972561c0ecbbdee8cdb92db4b803953808f7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Mon, 11 Mar 2024 13:51:43 +0100 Subject: [PATCH] Upgrade and apply Ruff linting --- fastapi_users/authentication/strategy/base.py | 11 +++++------ fastapi_users/authentication/transport/base.py | 6 ++---- fastapi_users/password.py | 9 +++------ pyproject.toml | 4 ++-- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/fastapi_users/authentication/strategy/base.py b/fastapi_users/authentication/strategy/base.py index 7dfbcdd6..518c9388 100644 --- a/fastapi_users/authentication/strategy/base.py +++ b/fastapi_users/authentication/strategy/base.py @@ -11,11 +11,10 @@ class StrategyDestroyNotSupportedError(Exception): class Strategy(Protocol, Generic[models.UP, models.ID]): async def read_token( self, token: Optional[str], user_manager: BaseUserManager[models.UP, models.ID] - ) -> Optional[models.UP]: - ... # pragma: no cover + ) -> Optional[models.UP]: ... # pragma: no cover - async def write_token(self, user: models.UP) -> str: - ... # pragma: no cover + async def write_token(self, user: models.UP) -> str: ... # pragma: no cover - async def destroy_token(self, token: str, user: models.UP) -> None: - ... # pragma: no cover + async def destroy_token( + self, token: str, user: models.UP + ) -> None: ... # pragma: no cover diff --git a/fastapi_users/authentication/transport/base.py b/fastapi_users/authentication/transport/base.py index d8b1acd9..fb69fc85 100644 --- a/fastapi_users/authentication/transport/base.py +++ b/fastapi_users/authentication/transport/base.py @@ -13,11 +13,9 @@ class TransportLogoutNotSupportedError(Exception): class Transport(Protocol): scheme: SecurityBase - async def get_login_response(self, token: str) -> Response: - ... # pragma: no cover + async def get_login_response(self, token: str) -> Response: ... # pragma: no cover - async def get_logout_response(self) -> Response: - ... # pragma: no cover + async def get_logout_response(self) -> Response: ... # pragma: no cover @staticmethod def get_openapi_login_responses_success() -> OpenAPIResponseType: diff --git a/fastapi_users/password.py b/fastapi_users/password.py index b6f44d0a..d7bfa783 100644 --- a/fastapi_users/password.py +++ b/fastapi_users/password.py @@ -7,14 +7,11 @@ from passlib.context import CryptContext class PasswordHelperProtocol(Protocol): def verify_and_update( self, plain_password: str, hashed_password: str - ) -> Tuple[bool, str]: - ... # pragma: no cover + ) -> Tuple[bool, str]: ... # pragma: no cover - def hash(self, password: str) -> str: - ... # pragma: no cover + def hash(self, password: str) -> str: ... # pragma: no cover - def generate(self) -> str: - ... # pragma: no cover + def generate(self) -> str: ... # pragma: no cover class PasswordHelper(PasswordHelperProtocol): diff --git a/pyproject.toml b/pyproject.toml index b80f5f71..841c2a31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,7 +82,7 @@ lint = [ "isort ./docs/src -o fastapi_users", "isort ./examples -o fastapi_users -p app", "ruff format .", - "ruff --fix .", + "ruff check --fix .", "mypy fastapi_users/", ] lint-check = [ @@ -90,7 +90,7 @@ lint-check = [ "isort --check-only ./docs/src -o fastapi_users", "isort --check-only ./examples -o fastapi_users -p app", "ruff format .", - "ruff .", + "ruff check .", "mypy fastapi_users/", ] docs = "mkdocs serve"