diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..03e320654 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,19 @@ +name: pre-commit + +on: + pull_request: + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v6 + + - uses: pre-commit/action@v3.0.1 + with: + # only run on files changed in this PR + extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml deleted file mode 100644 index 01691c3fb..000000000 --- a/.github/workflows/ruff.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Ruff -on: [push, pull_request] -jobs: - ruff: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 - with: - version: 0.2.2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 18bce2e2a..165a9a535 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ default_stages: [ pre-commit, pre-push ] exclude: ^src/(bin/|web_interface/static/package-lock.json) repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v6.0.0 hooks: - id: check-added-large-files args: [ --maxkb=10000 ] @@ -30,30 +30,29 @@ repos: exclude: ^src/web_interface/static/package-lock.json - repo: https://github.com/jumanjihouse/pre-commit-hooks - rev: 2.1.5 + rev: 3.0.0 hooks: - id: shellcheck - - repo: https://github.com/pryorda/dockerfilelint-precommit-hooks - rev: v0.1.0 + - repo: https://github.com/hadolint/hadolint + rev: v2.14.0 hooks: - - id: dockerfilelint + - id: hadolint - repo: https://github.com/pre-commit/mirrors-jshint - rev: v2.13.0 + rev: v2.13.6 hooks: - id: jshint - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.2.2' + rev: 'v0.14.11' hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] - id: ruff-format - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.35.0 + rev: v0.44.0 hooks: - id: markdownlint args: [ "--config", ".markdownlint.yaml" ] - diff --git a/pyproject.toml b/pyproject.toml index 49e2d6ea0..0be76e19d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,21 +26,20 @@ exclude = [ "src/plugins/analysis/input_vectors/internal", # FixMe: runs inside a bionic docker container with python 3.6 ] line-length = 120 -target-version = "py38" +target-version = "py310" [tool.ruff.lint] select = [ - "F", # Pyflakes - "E", # pycodestyle Error - "W", # pycodestyle Warning - "C90", # mccabe - "I", # isort - "N", # pep8-naming - "UP", # pyupgrade + # see https://docs.astral.sh/ruff/rules + "ERA", # eradicate + "YTT", # flake8-2020 + "ANN", # flake8-annotations + "S", # flake8-bandit (security) "B", # flake8-bugbear "A", # flake8-builtins "C4", # flake8-comprehensions "EXE", # flake8-executable + "FIX", # flake8-fixme "FA", # flake8-future-annotations "ISC", # flake8-implicit-str-concat "PIE", # flake8-pie @@ -49,26 +48,36 @@ select = [ "Q", # flake8-quotes "RET", # flake8-return "SIM", # flake8-simplify - "TCH", # flake8-type-checking + "TC", # flake8-type-checking "ARG", # flake8-unused-arguments "PTH", # flake8-use-pathlib - "ERA", # eradicate - "PL", # Pylint + "I", # isort + "C90", # mccabe + "N", # pep8-naming "PERF", # Perflint + "E", # pycodestyle Error + "W", # pycodestyle Warning + "F", # Pyflakes + "PLC", # Pylint + "PLE", # Pylint Error + "PLR", # Pylint Refactor + "PLW", # Pylint Warning + "UP", # pyupgrade + "FURB", # refurb (FURB code optimzations) "RUF", # Ruff-specific rules ] ignore = [ "A003", + "ANN204", # type annotation for special methods (e.g. __init__) "PERF203", "PERF401", "RUF001", "RUF002", "RUF003", "RUF015", - # pydantic only supports these from python>=3.9 - "UP006", - "UP007", - # rules may cause conflicts when used with the formatter + "FIX001", # line contains fixme + "FIX004", # line contains hack + # rules may cause conflicts when used with the formatter: "ISC001", "Q001", ]