diff --git a/app/controllers/cardManager.py b/app/controllers/cardManager.py index c5ca4af..128c739 100644 --- a/app/controllers/cardManager.py +++ b/app/controllers/cardManager.py @@ -69,7 +69,7 @@ def del_card( logger.info(f"The key:'{key}' was not found in db!") raise HTTPException( status.HTTP_500_INTERNAL_SERVER_ERROR, - detail="Key on card not found in DB. Please tell an admin about this. KEY={key}", + detail="Key on card not found in DB. Please tell an admin about this. KEY={key}", # noqa: E501 ) db.delete(card) db.commit() diff --git a/app/main.py b/app/main.py index ee17ddf..f8312e9 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,4 @@ import logging - -logger = logging.getLogger(__name__) import os from contextlib import asynccontextmanager @@ -11,6 +9,7 @@ from fastapi.security import OAuth2PasswordBearer load_dotenv() +# ruff: disable[E402] from app.controllers import ( aaManager, cardManager, @@ -24,6 +23,10 @@ from app.services.database import create_db_and_tables, get_db_session from app.services.scanner import BackgroundScanner from app.services.settings import verify_settings +# ruff: enable[E402] + +logger = logging.getLogger(__name__) + oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") scanner = BackgroundScanner(db=get_db_session()) logging.basicConfig(level=logging.INFO) diff --git a/app/services/settings.py b/app/services/settings.py index 4a5a2bf..9507e82 100644 --- a/app/services/settings.py +++ b/app/services/settings.py @@ -17,7 +17,7 @@ def verify_settings(): "DISABLE_CARDS" ): raise ValueError( - f"Missing environment variable for scanner start: {setting} \n Run with DISABLE_CARDS env var to disable cards" + f"Missing environment variable for scanner start: {setting} \n Run with DISABLE_CARDS env var to disable cards" # noqa: E501 ) for setting in important_envs: if setting not in os.environ or setting == "": diff --git a/pyproject.toml b/pyproject.toml index d6ec8a2..d911fe8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,20 @@ python-desfire = ["poetry"] py-modules = ["app"] [tool.ruff] -exclude = [ - "alembic" -] \ No newline at end of file +exclude = ["alembic"] +[tool.ruff.lint] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", +] +ignore = ["B008"] \ No newline at end of file diff --git a/test/test_services/test_card_manager.py b/test/test_services/test_card_manager.py index b76ec14..1992ba9 100644 --- a/test/test_services/test_card_manager.py +++ b/test/test_services/test_card_manager.py @@ -39,7 +39,7 @@ def test_update_card(client, auth_headers, test_group, test_card): data = response.json() assert data["name"] == "changed_name" - assert data["enabled"] == False + assert data["enabled"] == False # noqa: E712 assert data["group_id"] == test_card.group_id diff --git a/test/test_services/test_door.py b/test/test_services/test_door.py index e733738..855a185 100644 --- a/test/test_services/test_door.py +++ b/test/test_services/test_door.py @@ -42,8 +42,7 @@ def test_check_access_with_valid_timetable(db_session): db_session.commit() # Test: access should be granted within time window - result = checkAccess("test-key-123", db_session) - assert result == True + assert checkAccess("test-key-123", db_session) def test_check_access_outside_hours(db_session): @@ -74,8 +73,7 @@ def test_check_access_outside_hours(db_session): group.accessauths = [aa] db_session.commit() - result = checkAccess("test-key-123", db_session) - assert result == False + assert not checkAccess("test-key-123", db_session) def test_check_access_with_valid_oneshot(db_session): @@ -106,8 +104,7 @@ def test_check_access_with_valid_oneshot(db_session): db_session.commit() # Test: access should be granted within time window - result = checkAccess("test-key-123", db_session) - assert result == True + assert checkAccess("test-key-123", db_session) assert aa.oneshot.uses == 0