Skip to content
Merged

Fix qa #1909

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/backend-QA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ jobs:
working-directory: backend
run: |
pip install -U pip
pip install -e .[lint,scripts,test,check,api]
pip install -e .[qa,scripts,test,api]

- name: Check black formatting
- name: Check Linting
working-directory: backend
run: inv lint-black
run: inv check-lint

- name: Check ruff
- name: Check Formatting
working-directory: backend
run: inv lint-ruff
run: inv check-format

- name: Check pyright
- name: Check Type
working-directory: backend
run: inv check-pyright
run: inv check-type
14 changes: 7 additions & 7 deletions .github/workflows/healthcheck-QA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ jobs:
working-directory: healthcheck
run: |
pip install -U pip
pip install -e .[lint,scripts,test,check]
pip install -e .[qa,scripts,test]

- name: Check black formatting
- name: Check Linting
working-directory: healthcheck
run: inv lint-black
run: inv check-lint

- name: Check ruff
- name: Check Formatting
working-directory: healthcheck
run: inv lint-ruff
run: inv check-format

- name: Check pyright
- name: Check Type
working-directory: healthcheck
run: inv check-pyright
run: inv check-type
10 changes: 5 additions & 5 deletions .github/workflows/monitor-QA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ jobs:
working-directory: monitor/parent
run: |
pip install -U pip
pip install black ruff pyright
pip install ruff pyright

- name: Check black formatting
- name: Check Formatting
working-directory: monitor/parent
run: black --check --diff .
run: ruff format --check .

- name: Check ruff
- name: Check Linting
working-directory: monitor/parent
run: ruff check .

- name: Check pyright
- name: Check Type
working-directory: monitor/parent
run: pyright
14 changes: 7 additions & 7 deletions .github/workflows/recipesauto-QA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ jobs:
working-directory: recipesauto
run: |
pip install -U pip
pip install -e .[lint,scripts,test,check]
pip install -e .[qa,scripts,test]

- name: Check black formatting
- name: Check Linting
working-directory: recipesauto
run: inv lint-black
run: inv check-lint

- name: Check ruff
- name: Check Formatting
working-directory: recipesauto
run: inv lint-ruff
run: inv check-format

- name: Check pyright
- name: Check Type
working-directory: recipesauto
run: inv check-pyright
run: inv check-type
10 changes: 5 additions & 5 deletions .github/workflows/watcher-QA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
run: |
pip install -U pip
pip install -r requirements.txt
pip install black ruff pyright
pip install ruff pyright

- name: Check black formatting
- name: Check Formatting
working-directory: watcher
run: black --check --diff .
run: ruff format --check .

- name: Check ruff
- name: Check Linting
working-directory: watcher
run: ruff check .

- name: Check pyright
- name: Check Type
working-directory: watcher
run: pyright
14 changes: 7 additions & 7 deletions .github/workflows/worker-QA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ jobs:
working-directory: worker
run: |
pip install -U pip
pip install -e .[lint,scripts,test,check,task]
pip install -e .[qa,scripts,test,task]

- name: Check black formatting
- name: Check Linting
working-directory: worker
run: inv lint-black
run: inv check-lint

- name: Check ruff
- name: Check Formatting
working-directory: worker
run: inv lint-ruff
run: inv check-format

- name: Check pyright
- name: Check Type
working-directory: worker
run: inv check-pyright
run: inv check-type
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending

- repo: https://github.com/psf/black
rev: "25.1.0"
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.10
rev: v0.15.12
hooks:
- id: ruff-check
- id: ruff-format
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Before contributing, make sure you mention you'll be working on it in the associ
We have a very limited number of contributors so rules are quite limited:

- Submit your changes over a Pull Request
- Make sure all your python code is black formatted.
- Make sure all your python code is formatted with ruff.
- Make sure Codefactor reports no issue.
- API code (backend) must be tested. Make sure your PR doesn't decrease code coverage.

Expand Down
1 change: 0 additions & 1 deletion backend/V1_TO_V2_MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ Zimfarm Backend v2 represents a significant modernization of the codebase, migra

**v2 New Features:**

- Black code formatter
- Ruff linter
- Pyright type checker
- Pre-commit hooks
Expand Down
48 changes: 17 additions & 31 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]
dependencies = [
"alembic == 1.15.2",
"alembic == 1.18.4",
"pydantic[email] == 2.11.4",
"pydantic-extra-types == 2.10.6",
"SQLAlchemy == 2.0.41",
Expand All @@ -44,12 +44,9 @@ api = [
scripts = [
"invoke == 2.2.0",
]
lint = [
"black == 25.1.0",
"ruff == 0.11.10",
]
check = [
"pyright == 1.1.400",
qa = [
"ruff==0.15.12",
"pyright==1.1.409",
"types-humanfriendly == 10.0.0"
]
test = [
Expand All @@ -65,9 +62,8 @@ dev = [
"ipykernel == 6.29.5",
"zimfarm_backend[api]",
"zimfarm_backend[scripts]",
"zimfarm_backend[lint]",
"zimfarm_backend[qa]",
"zimfarm_backend[test]",
"zimfarm_backend[check]",
]

[project.urls]
Expand Down Expand Up @@ -103,29 +99,19 @@ report-cov = "inv report-cov"
coverage = "inv coverage --args '{args}'"
html = "inv coverage --html --args '{args}'"

[tool.hatch.envs.lint]
template = "lint"
[tool.hatch.envs.qa]
template = "qa"
skip-install = false
features = ["scripts", "lint"]

[tool.hatch.envs.lint.scripts]
black = "inv lint-black --args '{args}'"
ruff = "inv lint-ruff --args '{args}'"
all = "inv lintall --args '{args}'"
fix-black = "inv fix-black --args '{args}'"
fix-ruff = "inv fix-ruff --args '{args}'"
fixall = "inv fixall --args '{args}'"

[tool.hatch.envs.check]
features = ["scripts", "test", "check"]

[tool.hatch.envs.check.scripts]
pyright = "inv check-pyright --args '{args}'"
all = "inv checkall --args '{args}'"

[tool.black]
line-length = 88
target-version = ['py313']
features = ["scripts", "qa", "test"]

[tool.hatch.envs.qa.scripts]
check-lint = "inv check-lint --args '{args}'"
check-format = "inv check-format --args '{args}'"
check-type = "inv check-type --args '{args}'"
check-all = "inv check-all --args '{args}'"
fix-format = "inv fix-format --args '{args}'"
fix-lint = "inv fix-lint --args '{args}'"
fix-all = "inv fix-all --args '{args}'"

[tool.ruff]
line-length = 88
Expand Down
12 changes: 4 additions & 8 deletions backend/src/zimfarm_backend/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,10 @@ sqlalchemy.url = driver://user:pass@localhost/dbname
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
hooks = black isort
black.type = console_scripts
black.entrypoint = black
black.options = REVISION_SCRIPT_FILENAME
isort.type = console_scripts
isort.entrypoint = isort
isort.options = --profile black REVISION_SCRIPT_FILENAME
hooks = ruff
ruff.type = module
ruff.module = ruff
ruff.options = format REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
Expand Down
4 changes: 2 additions & 2 deletions backend/src/zimfarm_backend/api/routes/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Generic, TypeVar
from typing import TypeVar

from zimfarm_backend.common.schemas import BaseModel
from zimfarm_backend.common.schemas.models import Paginator

T = TypeVar("T")


class ListResponse(BaseModel, Generic[T]):
class ListResponse[T](BaseModel):
meta: Paginator
items: list[T]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ruff: noqa: UP007
# ruff: noqa: UP045
from collections.abc import Callable
from enum import Enum, StrEnum
from itertools import chain
Expand Down
6 changes: 4 additions & 2 deletions backend/src/zimfarm_backend/db/requested_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,10 @@ def filter_req_task_with_no_recipe_duration(task: RequestedTask):
[
create_requested_task_with_duration(session, task=task, worker=worker)
for task in filter(
lambda task: filter_req_task_for_ip_issues(task)
and filter_req_task_with_no_recipe_duration(task),
lambda task: (
filter_req_task_for_ip_issues(task)
and filter_req_task_with_no_recipe_duration(task)
),
session.scalars(query),
)
],
Expand Down
Loading
Loading