From f5d9108ecca283d3850616a3582aa0a6e63c584c Mon Sep 17 00:00:00 2001 From: Julien Maupetit Date: Fri, 6 Dec 2024 11:55:51 +0100 Subject: [PATCH] Fix linter issues --- .../versions/86b08ec6e6d1_add_auditability.py | 4 ++-- src/api/qualicharge/schemas/sql.py | 10 ++++++---- src/api/qualicharge/schemas/utils.py | 6 +++--- src/api/tests/api/v1/routers/test_statique.py | 5 ++++- src/api/tests/schemas/test_audit.py | 5 ----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/api/qualicharge/migrations/versions/86b08ec6e6d1_add_auditability.py b/src/api/qualicharge/migrations/versions/86b08ec6e6d1_add_auditability.py index b5fa6994..a9bae7a1 100644 --- a/src/api/qualicharge/migrations/versions/86b08ec6e6d1_add_auditability.py +++ b/src/api/qualicharge/migrations/versions/86b08ec6e6d1_add_auditability.py @@ -1,7 +1,7 @@ """add auditability Revision ID: 86b08ec6e6d1 -Revises: 6e610f62bcc6 +Revises: c09664a85912 Create Date: 2024-10-16 17:03:58.431420 """ @@ -14,7 +14,7 @@ # revision identifiers, used by Alembic. revision: str = "86b08ec6e6d1" -down_revision: Union[str, None] = "6e610f62bcc6" +down_revision: Union[str, None] = "c09664a85912" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None diff --git a/src/api/qualicharge/schemas/sql.py b/src/api/qualicharge/schemas/sql.py index 5b0d4ffe..405b7389 100644 --- a/src/api/qualicharge/schemas/sql.py +++ b/src/api/qualicharge/schemas/sql.py @@ -250,10 +250,12 @@ def _save_schema( f: stmt.excluded.get(f) for f in self._get_fields_for_schema(schema, with_fk=True) } - updates_on_conflict.update({ - "updated_at": stmt.excluded.updated_at, - "updated_by_id": stmt.excluded.updated_by_id, - }) + updates_on_conflict.update( + { + "updated_at": stmt.excluded.updated_at, + "updated_by_id": stmt.excluded.updated_by_id, + } + ) stmt = stmt.on_conflict_do_update( constraint=constraint, index_elements=index_elements, diff --git a/src/api/qualicharge/schemas/utils.py b/src/api/qualicharge/schemas/utils.py index 52259326..b168971b 100644 --- a/src/api/qualicharge/schemas/utils.py +++ b/src/api/qualicharge/schemas/utils.py @@ -9,10 +9,10 @@ from sqlalchemy import func from sqlalchemy.exc import MultipleResultsFound from sqlalchemy.schema import Column as SAColumn -from qualicharge.schemas.audit import BaseAuditableSQLModel from sqlmodel import Session, SQLModel, select from qualicharge.auth.schemas import User +from qualicharge.schemas.audit import BaseAuditableSQLModel from ..exceptions import ( DatabaseQueryException, @@ -91,7 +91,7 @@ def get_or_create( # Update database entry for key, value in entry.model_dump( - exclude=list(set(DB_TO_STATIC_EXCLUDED_FIELDS) - {"updated_by_id"}) + exclude=set(DB_TO_STATIC_EXCLUDED_FIELDS) - {"updated_by_id"} ).items(): setattr(db_entry, key, value) session.add(db_entry) @@ -105,7 +105,7 @@ def get_or_create( return EntryStatus.CREATED, entry -def save_schema_from_statique( +def save_schema_from_statique( # noqa: PLR0913 session: Session, schema_klass: Type[SQLModel], statique: Statique, diff --git a/src/api/tests/api/v1/routers/test_statique.py b/src/api/tests/api/v1/routers/test_statique.py index 87474da7..8705f04d 100644 --- a/src/api/tests/api/v1/routers/test_statique.py +++ b/src/api/tests/api/v1/routers/test_statique.py @@ -515,7 +515,10 @@ def test_update_for_superuser(client_auth, db_session): def test_update_audits(client_auth, db_session): - """Test the /statique/{id_pdc_itinerance} update endpoint audits (superuser case).""" + """Test the /statique/{id_pdc_itinerance} update endpoint audits. + + (superuser case) + """ id_pdc_itinerance = "FR911E1111ER1" db_statique = save_statique( db_session, diff --git a/src/api/tests/schemas/test_audit.py b/src/api/tests/schemas/test_audit.py index 36479194..f158d086 100644 --- a/src/api/tests/schemas/test_audit.py +++ b/src/api/tests/schemas/test_audit.py @@ -15,12 +15,7 @@ ) from qualicharge.schemas.audit import Audit from qualicharge.schemas.core import ( - Amenageur, - Enseigne, - Localisation, Operateur, - PointDeCharge, - Station, )