Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
ruff linting fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rubben-88 committed Mar 14, 2024
1 parent 0b27c44 commit b05c15f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion backend/db/errors/database_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, message: str) -> None:

class ActionAlreadyPerformedError(Exception):
"""
The specified action was already performed on the database once before
The specified action was already performed on the database once before
and may not be performed again as to keep consistency.
"""
def __init__(self, message: str) -> None:
Expand Down
21 changes: 10 additions & 11 deletions backend/db/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
The second variable in os.getenv specifies the default value.
"""
# where the database is hosted
db_host = os.getenv("DB_HOST", "localhost")
# port number on which the database server is listening
db_port = os.getenv("DB_PORT", "5432")
# username for the database
db_user = os.getenv("DB_USERNAME", "postgres")
# password for the user
db_password = os.getenv("DB_PASSWORD", "postgres")
# name of the database
db_database = os.getenv("DB_DATABASE", "delphi")
db_host = os.getenv("DB_HOST", "localhost")
# port number on which the database server is listening
db_port = os.getenv("DB_PORT", "5432")
# username for the database
db_user = os.getenv("DB_USERNAME", "postgres")
# password for the user
db_password = os.getenv("DB_PASSWORD", "postgres")
# name of the database
db_database = os.getenv("DB_DATABASE", "delphi")

# dialect+driver://username:password@host:port/database
DB_URI = f"postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_database}"
Expand All @@ -29,7 +29,6 @@

class Base(DeclarativeBase):
"""
This class is meant to be inherited from to define the database tables, see [db/models/models.py].
This class is meant to be inherited from to define the database tables, see [db/models/models.py].
For usage, please check https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/basic_use.html.
"""
pass
5 changes: 2 additions & 3 deletions backend/db/models/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import abstractmethod
from dataclasses import dataclass # automatically add special methods as __init__() and __repr__()
from dataclasses import dataclass # automatically add special methods as __init__() and __repr__()
from datetime import datetime
from typing import Generic, TypeVar

Expand All @@ -25,7 +25,7 @@
class AbstractModel(Generic[D]):
"""
This class is meant to be inherited by the python classes for the database tables.
It makes sure that every child implements the to_domain_model function
It makes sure that every child implements the to_domain_model function
and receives Pydantic data validation.
"""
@abstractmethod
Expand All @@ -34,7 +34,6 @@ def to_domain_model(self) -> D:
Change to an actual easy-to-use dataclass defined in [domain/models/*].
This prevents working with instances of SQLAlchemy's Base class.
"""
pass

# See the EER diagram for a more visual representation.

Expand Down
2 changes: 1 addition & 1 deletion backend/domain/logic/basic_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def get(session: Session, object_type: type[T], ident: int) -> T:
"""
General function for retrieving a single object from the database.
The type of the object and its id as well a session object has to be provided.
The type of the object and its id as well a session object has to be provided.
"""
generic_object: T | None = session.get(object_type, ident)

Expand Down
2 changes: 1 addition & 1 deletion backend/domain/models/UserDataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class UserDataclass(BaseModel):
"""
This user does not have any roles yet.
This user does not have any roles yet.
When the roles become specified, use the almost equivalent APIUser.
"""
id: int
Expand Down

0 comments on commit b05c15f

Please sign in to comment.