From 0870db9ebac1f3cfc37749981c858dbeb5f966bb Mon Sep 17 00:00:00 2001 From: Tim Weber Date: Wed, 7 Feb 2024 14:30:01 +0000 Subject: [PATCH] Add some Ruff ignores, enable it in GH Actions It's only reporting errors for now, I'll make it mandatory after having fixed or ignore a lot of errors :) --- .github/workflows/build.yaml | 3 +++ server/pyproject.toml | 18 ++++++++++++++++++ server/test.sh | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2a803887..02998690 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,6 +25,9 @@ jobs: sudo apt install -y graphviz graphviz-dev python3-dev python -m pip install poetry poetry install --all-extras + - name: Lint with Ruff + run: poetry run ruff + continue-on-error: true # temporary, until we've updated the codebase to Ruff's standards - name: Typecheck with mypy run: poetry run mypy - name: Test with pytest diff --git a/server/pyproject.toml b/server/pyproject.toml index 983efbb6..a6f05aac 100755 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -81,6 +81,11 @@ markers = [ [tool.ruff] line-length = 79 indent-width = 4 +target-version = "py38" +exclude = [ + ".git", + "migrations", +] [tool.ruff.format] quote-style = "double" @@ -129,6 +134,10 @@ ignore = [ "ANN102", # type annotation for @classmethod first argument "ISC001", # conflict w/ formatter, see https://github.com/astral-sh/ruff/issues/8272 "PLC0415", # forbids dynamic imports + "PT006", # forbids comma-separated string for @pytest.mark.parametrize names + "PT007", # forbids non-list types for @pytest.mark.parametrize values + "RUF001", # complains about Unicode typography in strings + "RUF002", # complains about Unicode typography in docstrings "RUF200", # requires a name for projects "TRY003", # complains about simple ValueError messages ] @@ -136,3 +145,12 @@ ignore = [ [tool.ruff.lint.isort] # Two blank lines after the imports. lines-after-imports = 2 + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "ANN001", # missing function argument annotation + "ANN201", # missing return type annotation + "ARG001", # unused function argument (e.g. require-only fixtures) + "INP001", # implicit namespace package + "S101", # use of assert +] diff --git a/server/test.sh b/server/test.sh index c5750a0b..517b36e7 100755 --- a/server/test.sh +++ b/server/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -poetry run sh -c 'ruff check && mypy && mypy tests && pytest && dearmep check translations' +poetry run sh -c 'ruff check; mypy && mypy tests && pytest && dearmep check translations'