From be4b9bc628822f19acb4465eab353e58108f48e4 Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 15:02:32 +0300 Subject: [PATCH 1/8] black --- .github/workflows/black.yml | 18 ++++++++++++++++++ calendar_backend/models/db.py | 12 +++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/black.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 00000000..d7db3e08 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,18 @@ +name: Lint + +on: + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: psf/black@stable + - name: Comment + if: ${{ failure() }} + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + :exclamation: Use black to format code :exclamation: + https://pypi.org/project/black/ 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( From f4b22fa242473b35120ff8e48a6f021a662740d0 Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 15:28:59 +0300 Subject: [PATCH 2/8] isort --- .github/workflows/isort.yml | 22 ++++++++++++++++++++++ requirements.dev.txt | 1 + 2 files changed, 23 insertions(+) create mode 100644 .github/workflows/isort.yml diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml new file mode 100644 index 00000000..f76feb6f --- /dev/null +++ b/.github/workflows/isort.yml @@ -0,0 +1,22 @@ +name: Run isort +on: + - push + +jobs: + isort: + 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" + - name: Comment + if: ${{ failure() }} + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + :exclamation: Use isort to format code :exclamation: + https://pycqa.github.io/isort/ \ No newline at end of file diff --git a/requirements.dev.txt b/requirements.dev.txt index 15533c0f..2704795e 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -5,3 +5,4 @@ pytest-mock black isort autoflake +isort From 1d85c396c0db179f4f52418b712bfe40c006f85b Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 15:38:56 +0300 Subject: [PATCH 3/8] isort --- .github/workflows/isort.yml | 2 +- calendar_backend/routes/base.py | 5 ++--- migrations/versions/3948c45f9977_building_url.py | 3 ++- migrations/versions/63263ee9e08e_fix_photo_paths.py | 2 +- migrations/versions/fe04c8baa5ab_fix_sa20.py | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml index f76feb6f..660e749c 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/isort.yml @@ -1,6 +1,6 @@ name: Run isort on: - - push + pull_request: jobs: isort: diff --git a/calendar_backend/routes/base.py b/calendar_backend/routes/base.py index e40c7ca3..a7117bb2 100644 --- a/calendar_backend/routes/base.py +++ b/calendar_backend/routes/base.py @@ -26,9 +26,8 @@ from .gcal import gcal 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 +from .lecturer import \ + 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' From c96daa68e66ef59d2fbe28c703fa27f017f455a6 Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 15:48:00 +0300 Subject: [PATCH 4/8] isort --- calendar_backend/routes/base.py | 5 +++-- pyproject.toml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/calendar_backend/routes/base.py b/calendar_backend/routes/base.py index a7117bb2..578b8e1e 100644 --- a/calendar_backend/routes/base.py +++ b/calendar_backend/routes/base.py @@ -26,8 +26,9 @@ from .gcal import gcal 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 +from .lecturer import ( + 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/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 From 1bf66990897a75714a3e776cf5e07831b5e0ea89 Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 16:24:17 +0300 Subject: [PATCH 5/8] isort --- .github/workflows/black.yml | 18 ------------------ .github/workflows/{isort.yml => lint.yml} | 10 ++++++---- 2 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/black.yml rename .github/workflows/{isort.yml => lint.yml} (72%) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index d7db3e08..00000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Lint - -on: - pull_request: - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: psf/black@stable - - name: Comment - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - :exclamation: Use black to format code :exclamation: - https://pypi.org/project/black/ diff --git a/.github/workflows/isort.yml b/.github/workflows/lint.yml similarity index 72% rename from .github/workflows/isort.yml rename to .github/workflows/lint.yml index 660e749c..c8786873 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,8 @@ -name: Run isort +name: Run lint on: pull_request: + jobs: isort: runs-on: ubuntu-latest @@ -13,10 +14,11 @@ jobs: - uses: isort/isort-action@master with: requirementsFiles: "requirements.txt requirements.dev.txt" - - name: Comment + - uses: psf/black@stable + - name: Comment if linting failed if: ${{ failure() }} uses: thollander/actions-comment-pull-request@v2 with: message: | - :exclamation: Use isort to format code :exclamation: - https://pycqa.github.io/isort/ \ No newline at end of file + :poop: Code linting failed, use `black` and `isort` to fix it. + From c050695313dab1bce8879f0c1a6140fee9d91fe4 Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 16:26:37 +0300 Subject: [PATCH 6/8] lint --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c8786873..ef5fa459 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,7 +4,7 @@ on: jobs: - isort: + linting: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From a6de567c83202a9c9f772bb75090ffcf63afce9d Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 17:03:17 +0300 Subject: [PATCH 7/8] lint --- .github/workflows/lint.yml | 24 ------------------------ .github/workflows/tests.yml | 17 +++++++++++++++++ requirements.dev.txt | 1 - 3 files changed, 17 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index ef5fa459..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Run lint -on: - pull_request: - - -jobs: - 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/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5233a83b..e150425a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.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/requirements.dev.txt b/requirements.dev.txt index 2704795e..15533c0f 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -5,4 +5,3 @@ pytest-mock black isort autoflake -isort From 1d755b5c1ffec86e8e524ab3c18aee4bb32a0c9d Mon Sep 17 00:00:00 2001 From: semen603089 Date: Sun, 26 Mar 2023 17:05:44 +0300 Subject: [PATCH 8/8] lint --- .github/workflows/{tests.yml => checks.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{tests.yml => checks.yml} (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/checks.yml similarity index 100% rename from .github/workflows/tests.yml rename to .github/workflows/checks.yml