[lint] more linting changes
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 == "":
|
||||
|
||||
@@ -31,6 +31,20 @@ python-desfire = ["poetry"]
|
||||
py-modules = ["app"]
|
||||
|
||||
[tool.ruff]
|
||||
exclude = [
|
||||
"alembic"
|
||||
]
|
||||
exclude = ["alembic"]
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
# pycodestyle
|
||||
"E",
|
||||
# Pyflakes
|
||||
"F",
|
||||
# pyupgrade
|
||||
"UP",
|
||||
# flake8-bugbear
|
||||
"B",
|
||||
# flake8-simplify
|
||||
"SIM",
|
||||
# isort
|
||||
"I",
|
||||
]
|
||||
ignore = ["B008"]
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user