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

Commit

Permalink
Lint code and revert pydantic for now
Browse files Browse the repository at this point in the history
  • Loading branch information
msathieu committed Feb 28, 2024
1 parent ede6c1f commit 94f798b
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 37 deletions.
5 changes: 2 additions & 3 deletions backend/db/implementation/SqlAbstractDAO.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from sqlalchemy import select
from abc import ABC
from typing import Generic, TypeVar

from sqlalchemy import select
from sqlalchemy.orm import Session

from db.errors.database_errors import ItemNotFoundError
from db.extensions import engine
from typing import Generic, TypeVar, Type

from db.models.models import AbstractModel

T = TypeVar("T", bound=AbstractModel)
Expand Down
4 changes: 2 additions & 2 deletions backend/db/implementation/SqlGroupDAO.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from db.errors.database_errors import ItemNotFoundError, UniqueConstraintError
from db.extensions import engine
from sqlalchemy.orm import Session

from db.errors.database_errors import ItemNotFoundError, UniqueConstraintError
from db.extensions import engine
from db.implementation.SqlAbstractDAO import SqlAbstractDAO
from db.interface.GroupDAO import GroupDAO
from db.models.models import Group, Project, Student
Expand Down
3 changes: 1 addition & 2 deletions backend/db/implementation/SqlProjectDAO.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from datetime import datetime

from db.errors.database_errors import ItemNotFoundError
from sqlalchemy.orm import Session

from db.errors.database_errors import ItemNotFoundError
from db.extensions import engine
from db.implementation.SqlAbstractDAO import SqlAbstractDAO
from db.interface.AbstractDAO import D
from db.interface.ProjectDAO import ProjectDAO
from db.models.models import Project, Subject
from domain.models.ProjectDataclass import ProjectDataclass
Expand Down
5 changes: 1 addition & 4 deletions backend/db/implementation/SqlStudentDAO.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from sqlalchemy import select

from db.errors.database_errors import ItemNotFoundError
from db.extensions import engine
from sqlalchemy.orm import Session

from db.extensions import engine
from db.implementation.SqlAbstractDAO import SqlAbstractDAO
from db.interface.AbstractDAO import D
from db.interface.StudentDAO import StudentDAO
from db.models.models import Student
from domain.models.StudentDataclass import StudentDataclass
Expand Down
3 changes: 1 addition & 2 deletions backend/db/implementation/SqlSubjectDAO.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from db.errors.database_errors import ItemNotFoundError, UniqueConstraintError
from sqlalchemy.orm import Session

from db.errors.database_errors import ItemNotFoundError, UniqueConstraintError
from db.extensions import engine
from db.implementation.SqlAbstractDAO import SqlAbstractDAO
from db.interface.AbstractDAO import D
from db.interface.SubjectDAO import SubjectDAO
from db.models.models import Student, Subject, Teacher
from domain.models.SubjectDataclass import SubjectDataclass
Expand Down
2 changes: 1 addition & 1 deletion backend/db/implementation/SqlSubmissionDAO.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from datetime import datetime

from db.errors.database_errors import ItemNotFoundError
from sqlalchemy.orm import Session

from db.errors.database_errors import ItemNotFoundError
from db.extensions import engine
from db.implementation.SqlAbstractDAO import SqlAbstractDAO
from db.interface.SubmissionDAO import SubmissionDAO
Expand Down
2 changes: 1 addition & 1 deletion backend/db/implementation/SqlTeacherDAO.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sqlalchemy.orm import Session

from db.extensions import engine
from db.implementation.SqlAbstractDAO import SqlAbstractDAO
from db.interface.AbstractDAO import D
from db.interface.TeacherDAO import TeacherDAO
from db.models.models import Teacher
from domain.models.TeacherDataclass import TeacherDataclass
Expand Down
2 changes: 0 additions & 2 deletions backend/db/interface/AbstractDAO.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from abc import ABC, abstractmethod
from typing import Generic, TypeVar

from db.models.models import AbstractModel

T = TypeVar("T")
D = TypeVar("D")

Expand Down
4 changes: 2 additions & 2 deletions backend/db/models/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from abc import abstractmethod
from dataclasses import dataclass
from datetime import datetime
from typing import Any

from sqlalchemy import Column, ForeignKey, Table
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship

from domain.models.AdminDataclass import AdminDataclass
from domain.models.base_model import JsonRepresentable
from domain.models.GroupDataclass import GroupDataclass
from domain.models.ProjectDataclass import ProjectDataclass
from domain.models.StudentDataclass import StudentDataclass
Expand All @@ -19,7 +19,7 @@
@dataclass()
class AbstractModel:
@abstractmethod
def to_domain_model(self) -> Any:
def to_domain_model(self) -> JsonRepresentable:
pass


Expand Down
7 changes: 1 addition & 6 deletions backend/domain/models/TeacherDataclass.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from dataclasses import dataclass

from domain.models.UserDataclass import UserDataclass, UserDataClassRequest
from domain.models.UserDataclass import UserDataclass


@dataclass()
class TeacherDataclass(UserDataclass):
pass


@dataclass()
class TeacherDataClassRequest(UserDataClassRequest):
pass
11 changes: 2 additions & 9 deletions backend/domain/models/UserDataclass.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
from dataclasses import dataclass

from pydantic import BaseModel
from domain.models.base_model import JsonRepresentable


@dataclass()
class UserDataclass(BaseModel):
class UserDataclass(JsonRepresentable):
id: int
# pydanitc will throw an error when creating a new user
name: str
email: str


@dataclass()
class UserDataClassRequest(BaseModel):
name: str
email: str
1 change: 0 additions & 1 deletion backend/domain/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from dataclasses import dataclass


# what is the use of this class when one can use pydantic models?
@dataclass()
class JsonRepresentable:
def to_dict(self) -> dict:
Expand Down
4 changes: 2 additions & 2 deletions backend/fill_database_mock.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from datetime import datetime

from psycopg2 import tz

from db.extensions import engine, Base
from sqlalchemy.orm import Session

from db.extensions import Base, engine
from db.implementation.SqlAdminDAO import SqlAdminDAO
from db.implementation.SqlGroupDAO import SqlGroupDAO
from db.implementation.SqlProjectDAO import SqlProjectDAO
Expand Down

0 comments on commit 94f798b

Please sign in to comment.