Skip to content

Commit

Permalink
database - fix errors with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed May 29, 2024
1 parent 4dbbd51 commit 1588030
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions acacore/database/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from acacore.utils.functions import or_none

from .column import Column
from .column import Index
from .column import dump_object
from .column import Index
from .column import model_to_columns
from .column import model_to_indices
from .column import SelectColumn
Expand Down Expand Up @@ -241,7 +241,13 @@ def fetchone(self, model: Optional[Type[M]] = None) -> Optional[M]:

# noinspection SqlNoDataSourceInspection
class Table:
def __init__(self, connection: "FileDBBase", name: str, columns: list[Column], indices: list[Index] | None = None):
def __init__(
self,
connection: "FileDBBase",
name: str,
columns: list[Column],
indices: list[Index] | None = None,
) -> None:
"""
A class that holds information about a table.
Expand Down Expand Up @@ -398,7 +404,7 @@ def insert_many(


class ModelTable(Table, Generic[M]):
def __init__(self, connection: "FileDBBase", name: str, model: Type[M], indices: list[Index] | None = None):
def __init__(self, connection: "FileDBBase", name: str, model: Type[M], indices: list[Index] | None = None) -> None:
"""
A class that holds information about a table using a model.
Expand Down
2 changes: 1 addition & 1 deletion acacore/database/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def model_to_indices(model: Type[BaseModel]) -> list["Index"]:
indices: list[tuple[Column, str]] = [
(columns[p], idx) for p, s in schema["properties"].items() if (idxs := s.get("index")) for idx in idxs
]
indices_merged = reduce(lambda idxs, c: idxs | {c[1]: idxs.get(c[1], []) + [c[0]]}, indices, {})
indices_merged = reduce(lambda idxs, c: idxs | {c[1]: [*idxs.get(c[1], []), c[0]]}, indices, {})
return [Index(n, cs) for n, cs in indices_merged.items()]


Expand Down

0 comments on commit 1588030

Please sign in to comment.