diff --git a/.github/workflows/tests.yml b/.github/workflows/checks.yml similarity index 69% rename from .github/workflows/tests.yml rename to .github/workflows/checks.yml index 5233a83b..e150425a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/checks.yml @@ -36,3 +36,20 @@ jobs: cat pytest-coverage.txt - name: Comment coverage uses: coroo/pytest-coverage-commentator@v1.0.2 + linting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.11 + - uses: isort/isort-action@master + with: + requirementsFiles: "requirements.txt requirements.dev.txt" + - uses: psf/black@stable + - name: Comment if linting failed + if: ${{ failure() }} + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + :poop: Code linting failed, use `black` and `isort` to fix it. diff --git a/calendar_backend/models/db.py b/calendar_backend/models/db.py index 2fdf4362..e3a9237a 100644 --- a/calendar_backend/models/db.py +++ b/calendar_backend/models/db.py @@ -23,7 +23,9 @@ class Credentials(BaseDbModel): scope: Mapped[JSON] = mapped_column(JSON, nullable=False) token: Mapped[JSON] = mapped_column(JSON, nullable=False) create_ts: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow) - update_ts: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) + update_ts: Mapped[datetime] = mapped_column( + DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow + ) class Direction(str, Enum): @@ -174,7 +176,9 @@ class CommentLecturer(BaseDbModel): text: Mapped[str] = mapped_column(String, nullable=False) approve_status: Mapped[ApproveStatuses] = mapped_column(DbEnum(ApproveStatuses, native_enum=False), nullable=False) create_ts: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow()) - update_ts: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow(), onupdate=datetime.utcnow()) + update_ts: Mapped[datetime] = mapped_column( + DateTime, nullable=False, default=datetime.utcnow(), onupdate=datetime.utcnow() + ) is_deleted: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False) lecturer: Mapped[Lecturer] = relationship( @@ -191,7 +195,9 @@ class CommentEvent(BaseDbModel): text: Mapped[str] = mapped_column(String, nullable=False) approve_status: Mapped[ApproveStatuses] = mapped_column(DbEnum(ApproveStatuses, native_enum=False), nullable=False) create_ts: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow()) - update_ts: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow(), onupdate=datetime.utcnow()) + update_ts: Mapped[datetime] = mapped_column( + DateTime, nullable=False, default=datetime.utcnow(), onupdate=datetime.utcnow() + ) is_deleted: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False) event: Mapped[Event] = relationship( diff --git a/calendar_backend/routes/base.py b/calendar_backend/routes/base.py index e40c7ca3..578b8e1e 100644 --- a/calendar_backend/routes/base.py +++ b/calendar_backend/routes/base.py @@ -27,8 +27,8 @@ from .group import group_router as old_group_router # DEPRICATED TODO: Drop 2023-04-01 from .group.group import router as group_router from .lecturer import ( - lecturer_comment_review_router as old_lecturer_comment_review_router, -) # DEPRICATED TODO: Drop 2023-04-01 + lecturer_comment_review_router as old_lecturer_comment_review_router, # DEPRICATED TODO: Drop 2023-04-01 +) from .lecturer import lecturer_comment_router as old_lecturer_comment_router # DEPRICATED TODO: Drop 2023-04-01 from .lecturer import lecturer_photo_router as old_lecturer_photo_router # DEPRICATED TODO: Drop 2023-04-01 from .lecturer import lecturer_router as old_lecturer_router # DEPRICATED TODO: Drop 2023-04-01 diff --git a/migrations/versions/3948c45f9977_building_url.py b/migrations/versions/3948c45f9977_building_url.py index 75e4f0d8..95b4e68b 100644 --- a/migrations/versions/3948c45f9977_building_url.py +++ b/migrations/versions/3948c45f9977_building_url.py @@ -5,8 +5,9 @@ Create Date: 2023-03-20 16:42:54.345727 """ -from alembic import op import sqlalchemy as sa +from alembic import op + # revision identifiers, used by Alembic. revision = '3948c45f9977' diff --git a/migrations/versions/63263ee9e08e_fix_photo_paths.py b/migrations/versions/63263ee9e08e_fix_photo_paths.py index 4afb474b..0e9558e4 100644 --- a/migrations/versions/63263ee9e08e_fix_photo_paths.py +++ b/migrations/versions/63263ee9e08e_fix_photo_paths.py @@ -5,8 +5,8 @@ Create Date: 2023-03-20 15:15:20.345969 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. diff --git a/migrations/versions/fe04c8baa5ab_fix_sa20.py b/migrations/versions/fe04c8baa5ab_fix_sa20.py index 08fb663c..b00b3fcd 100644 --- a/migrations/versions/fe04c8baa5ab_fix_sa20.py +++ b/migrations/versions/fe04c8baa5ab_fix_sa20.py @@ -5,10 +5,11 @@ Create Date: 2023-03-20 18:10:29.098467 """ -from alembic import op import sqlalchemy as sa +from alembic import op from sqlalchemy.dialects import postgresql + # revision identifiers, used by Alembic. revision = 'fe04c8baa5ab' down_revision = '3948c45f9977' diff --git a/pyproject.toml b/pyproject.toml index 2368eb97..6b889857 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ skip-string-normalization = true [tool.isort] line_length = 120 multi_line_output = 3 +profile = "black" lines_after_imports = 2 include_trailing_comma = true