Skip to content

Commit 03e949e

Browse files
committed
WIP: fix black & ruff linter issues
1 parent 2734d8d commit 03e949e

File tree

8 files changed

+21
-18
lines changed

8 files changed

+21
-18
lines changed

src/api/qualicharge/api/v1/routers/static.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
from annotated_types import Len
77
from fastapi import APIRouter, Depends, HTTPException, Path, Query, Request, status
88
from pydantic import AnyHttpUrl, BaseModel, computed_field
9-
from qualicharge.schemas.static import PointDeCharge
109
from sqlalchemy import func
1110
from sqlmodel import Session, select
1211

1312
from qualicharge.conf import settings
1413
from qualicharge.db import get_session
1514
from qualicharge.models.static import Statique
15+
from qualicharge.schemas.static import PointDeCharge
1616
from qualicharge.schemas.utils import (
1717
build_statique,
1818
list_statique,
@@ -138,9 +138,7 @@ async def create(
138138
statique: Statique, session: Session = Depends(get_session)
139139
) -> StatiqueItemsCreatedResponse:
140140
"""Create a statique item."""
141-
return StatiqueItemsCreatedResponse(
142-
items=[save_statique(session, statique)]
143-
)
141+
return StatiqueItemsCreatedResponse(items=[save_statique(session, statique)])
144142

145143

146144
@router.post("/bulk", status_code=status.HTTP_201_CREATED)

src/api/qualicharge/db.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def callback(self, *args, **kwargs):
7979
"""Increment the counter every time the `before_cursor_execute` event occurs."""
8080
self.count += 1
8181
logger.debug(f"Database query [{self.count=}] >> {args=} {kwargs=}")
82-
print(f"Database query [{self.count=}] >> {args=} {kwargs=}\n")
8382

8483

8584
def get_engine() -> SAEngine:

src/api/qualicharge/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ class ModelSerializerException(QualiChargeExceptionMixin, Exception):
2424
class DatabaseQueryException(QualiChargeExceptionMixin, Exception):
2525
"""Raised when a database query does not provide expected results."""
2626

27+
2728
class DuplicateEntriesSubmitted(QualiChargeExceptionMixin, Exception):
2829
"""Raised when submitted batch contains duplicated entries."""

src/api/qualicharge/migrations/versions/8580168c2cef_add_location_address_unique_constraint.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@
55
Create Date: 2024-04-29 17:23:43.423327
66
77
"""
8+
89
from typing import Sequence, Union
910

1011
from alembic import op
1112
import sqlalchemy as sa
1213
from sqlalchemy.dialects import postgresql
1314

1415
# revision identifiers, used by Alembic.
15-
revision: str = '8580168c2cef'
16-
down_revision: Union[str, None] = 'da896549e09c'
16+
revision: str = "8580168c2cef"
17+
down_revision: Union[str, None] = "da896549e09c"
1718
branch_labels: Union[str, Sequence[str], None] = None
1819
depends_on: Union[str, Sequence[str], None] = None
1920

2021

2122
def upgrade() -> None:
2223
# ### commands auto generated by Alembic - please adjust! ###
23-
op.create_unique_constraint(None, 'localisation', ['adresse_station'])
24+
op.create_unique_constraint(None, "localisation", ["adresse_station"])
2425
# ### end Alembic commands ###
2526

2627

2728
def downgrade() -> None:
2829
# ### commands auto generated by Alembic - please adjust! ###
29-
op.drop_constraint(None, 'localisation', type_='unique')
30+
op.drop_constraint(None, "localisation", type_="unique")
3031
# ### end Alembic commands ###

src/api/qualicharge/migrations/versions/da896549e09c_remove_location_unique_together_.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,33 @@
55
Create Date: 2024-04-29 17:20:56.671209
66
77
"""
8+
89
from typing import Sequence, Union
910

1011
from alembic import op
1112
import sqlalchemy as sa
1213
from sqlalchemy.dialects import postgresql
1314

1415
# revision identifiers, used by Alembic.
15-
revision: str = 'da896549e09c'
16-
down_revision: Union[str, None] = 'b7d33b01adac'
16+
revision: str = "da896549e09c"
17+
down_revision: Union[str, None] = "b7d33b01adac"
1718
branch_labels: Union[str, Sequence[str], None] = None
1819
depends_on: Union[str, Sequence[str], None] = None
1920

2021

2122
def upgrade() -> None:
2223
# ### commands auto generated by Alembic - please adjust! ###
23-
op.drop_constraint('localisation_adresse_station_coordonneesXY_key', 'localisation', type_='unique')
24+
op.drop_constraint(
25+
"localisation_adresse_station_coordonneesXY_key", "localisation", type_="unique"
26+
)
2427
# ### end Alembic commands ###
2528

2629

2730
def downgrade() -> None:
2831
# ### commands auto generated by Alembic - please adjust! ###
29-
op.create_unique_constraint('localisation_adresse_station_coordonneesXY_key', 'localisation', ['adresse_station', 'coordonneesXY'])
32+
op.create_unique_constraint(
33+
"localisation_adresse_station_coordonneesXY_key",
34+
"localisation",
35+
["adresse_station", "coordonneesXY"],
36+
)
3037
# ### end Alembic commands ###

src/api/qualicharge/schemas/static.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""QualiCharge static schemas."""
22

3-
import re
43
from typing import List, Optional, Union
54
from uuid import UUID, uuid4
65

@@ -21,7 +20,6 @@
2120
from sqlmodel import Field, Relationship, UniqueConstraint
2221
from sqlmodel.main import SQLModelConfig
2322

24-
from ..exceptions import ModelSerializerException
2523
from ..models.static import (
2624
AccessibilitePMREnum,
2725
ConditionAccesEnum,

src/api/qualicharge/schemas/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""QualiCharge schemas utilities."""
22

3-
from collections import namedtuple
43
import logging
54
from typing import Generator, List, NamedTuple, Optional, Set, Tuple, Type
65

@@ -23,7 +22,7 @@
2322
DB_TO_STATIC_EXCLUDED_FIELDS = {"id", "created_at", "updated_at"}
2423

2524

26-
def get_or_create(
25+
def get_or_create( # noqa: PLR0913
2726
session: Session,
2827
entry: SQLModel,
2928
fields: Optional[Set] = None,

src/api/tests/schemas/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import pytest
44
from sqlalchemy import func
5-
from qualicharge.db import SAQueryCounter
65
from sqlmodel import select
76

7+
from qualicharge.db import SAQueryCounter
88
from qualicharge.exceptions import DatabaseQueryException, DuplicateEntriesSubmitted
99
from qualicharge.factories.static import AmenageurFactory, StatiqueFactory
1010
from qualicharge.schemas.static import (

0 commit comments

Comments
 (0)