diff --git a/.github/workflows/test-only.yml b/.github/workflows/test-only.yml index dbdaa7fb..db5c3fbd 100644 --- a/.github/workflows/test-only.yml +++ b/.github/workflows/test-only.yml @@ -8,13 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Lint with flake8 + - name: Lint with Ruff run: | - pip3 install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + pip install ruff + # Check for syntax errors and undefined names + ruff check . --select E9,F63,F7,F82 + # Complete check with errors treated as warnings + ruff check . --exit-zero test-application-3-10: needs: lint-code @@ -41,5 +41,4 @@ jobs: uses: ./.github/workflows/test-stack-reusable-workflow.yml with: python-version: '3.13' - skip-pypuppeteer: true - + skip-pypuppeteer: true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 835597c3..dd2bcc3d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ dist/ .env .venv/ venv/ +.python-version # IDEs .idea diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..cb387e44 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.2 + hooks: + # Lint (and apply safe fixes) + - id: ruff + args: [--fix] + # Fomrat + - id: ruff-format diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 00000000..a58e4766 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,48 @@ +# Minimum supported version +target-version = "py310" + +# Formatting options +line-length = 100 +indent-width = 4 + +exclude = [ + "__pycache__", + ".eggs", + ".git", + ".tox", + ".venv", + "*.egg-info", + "*.pyc", +] + +[lint] +# https://docs.astral.sh/ruff/rules/ +select = [ + "B", # flake8-bugbear + "B9", + "C", + "E", # pycodestyle + "F", # Pyflakes + "I", # isort + "N", # pep8-naming + "UP", # pyupgrade + "W", # pycodestyle +] +ignore = [ + "B007", # unused-loop-control-variable + "B909", # loop-iterator-mutation + "E203", # whitespace-before-punctuation + "E266", # multiple-leading-hashes-for-block-comment + "E501", # redundant-backslash + "F403", # undefined-local-with-import-star + "N802", # invalid-function-name + "N806", # non-lowercase-variable-in-function + "N815", # mixed-case-variable-in-class-scope +] + +[lint.mccabe] +max-complexity = 12 + +[format] +indent-style = "space" +quote-style = "preserve" diff --git a/requirements.txt b/requirements.txt index 745503f5..83f97720 100644 --- a/requirements.txt +++ b/requirements.txt @@ -110,3 +110,6 @@ pluggy ~= 1.5 # Needed for testing, cross-platform for process and system monitoring psutil==7.0.0 + +ruff >= 0.11.2 +pre_commit >= 4.2.0