From 73f905620bab5c70da58174a70e56c1b66e4bde2 Mon Sep 17 00:00:00 2001 From: Florian Kromer Date: Wed, 29 Oct 2025 21:54:04 +0100 Subject: [PATCH 1/3] ci: add ruff workflow --- .github/workflows/ruff.yml | 48 +++++++++++++++++++++++++++++++++++++ pyproject.toml | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .github/workflows/ruff.yml diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 00000000..9f0e67c1 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,48 @@ +name: ruff + +on: + push: + # temporary disabled during development + # branches: + # - master + pull_request: + branches: + - master + +permissions: + # write permissions required to apply safe fixes + contents: write + +jobs: + ruff: + runs-on: ubuntu-latest + steps: + # https://github.com/actions/checkout + - name: Checkout code + uses: actions/checkout@v5 + with: + sparse-checkout: | + pytm + pyproject.toml + .github/workflows/ruff.yml + # https://github.com/astral-sh/ruff-action + # https://docs.astral.sh/ruff/formatter/ + - name: Format production code + uses: astral-sh/ruff-action@v3 + with: + src: pytm + version: "latest" + args: "format --check" + # https://docs.astral.sh/ruff/linter/ + - name: Fix production code (safe fixes only) + uses: astral-sh/ruff-action@v3 + with: + src: pytm + version: "latest" + args: "check --fix" + - name: Show unsafe production code fixes + uses: astral-sh/ruff-action@v3 + with: + src: pytm + version: "latest" + args: "check --fix --unsafe-fixes" diff --git a/pyproject.toml b/pyproject.toml index 56a5d28c..5b6e47e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,3 +16,52 @@ pdoc3 = "^0.11.6" [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" + +[tool.ruff] +target-version = "py310" + +# https://docs.astral.sh/ruff/settings/#analyze +[tool.ruff.analyze] +detect-string-imports = false +direction = "dependencies" +exclude = [] +include-dependencies = {} +preview = false +string-imports-min-dots = 2 + +# https://docs.astral.sh/ruff/settings/#format +[tool.ruff.format] +docstring-code-format = true +docstring-code-line-length = "dynamic" +exclude = [] +indent-style = "space" +line-ending = "lf" +preview = false +quote-style = "double" +skip-magic-trailing-comma = false + +# https://docs.astral.sh/ruff/settings/#lint +[tool.ruff.lint] +allowed-confusables = [] +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +exclude = [] +explicit-preview-rules = false +extend-fixable = [] +extend-ignore = [] +extend-per-file-ignores = {} +extend-safe-fixes = [] +extend-select = [] +extend-unsafe-fixes = [] +external = [] +fixable = ["ALL"] +future-annotations = false +ignore = [] +ignore-init-module-imports = true +logger-objects = [] +per-file-ignores = {} +preview = false +select = ["E4", "E7", "E9", "F"] +task-tags = ["TODO", "FIXME", "XXX"] +typing-extensions = true +typing-modules = [] +unfixable = [] From 957453fc378d19f53a952d0abd43a7b0cd891d0f Mon Sep 17 00:00:00 2001 From: Florian Kromer Date: Wed, 29 Oct 2025 21:57:16 +0100 Subject: [PATCH 2/3] ci: enable ruff auto fixing --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 9f0e67c1..d18364c1 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -32,7 +32,7 @@ jobs: with: src: pytm version: "latest" - args: "format --check" + args: "format" # https://docs.astral.sh/ruff/linter/ - name: Fix production code (safe fixes only) uses: astral-sh/ruff-action@v3 From a7dc1f9b7dc158b1166adbd78c9518ce09402cc5 Mon Sep 17 00:00:00 2001 From: Florian Kromer Date: Wed, 29 Oct 2025 22:08:26 +0100 Subject: [PATCH 3/3] ci: kiss... check and help only --- .github/workflows/ruff.yml | 28 +++++++++++++++++----------- pyproject.toml | 1 - 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index d18364c1..bb0e8538 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -2,16 +2,14 @@ name: ruff on: push: - # temporary disabled during development - # branches: - # - master + branches: + - master pull_request: branches: - master permissions: - # write permissions required to apply safe fixes - contents: write + contents: read jobs: ruff: @@ -27,22 +25,30 @@ jobs: .github/workflows/ruff.yml # https://github.com/astral-sh/ruff-action # https://docs.astral.sh/ruff/formatter/ - - name: Format production code + - name: Check production code format + uses: astral-sh/ruff-action@v3 + with: + src: pytm + version: "latest" + args: "format --check" + - name: Check production code uses: astral-sh/ruff-action@v3 with: src: pytm version: "latest" - args: "format" + args: "check --output-format=github" # https://docs.astral.sh/ruff/linter/ - - name: Fix production code (safe fixes only) + - name: Show helpful safe production code fixes uses: astral-sh/ruff-action@v3 with: src: pytm version: "latest" - args: "check --fix" - - name: Show unsafe production code fixes + args: "check --fix --diff --output-format=github" + continue-on-error: true + - name: Show potentially helpful unsafe production code fixes uses: astral-sh/ruff-action@v3 with: src: pytm version: "latest" - args: "check --fix --unsafe-fixes" + args: "check --fix --diff --unsafe-fixes --output-format=github" + continue-on-error: true diff --git a/pyproject.toml b/pyproject.toml index 5b6e47e2..8db78490 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,6 @@ external = [] fixable = ["ALL"] future-annotations = false ignore = [] -ignore-init-module-imports = true logger-objects = [] per-file-ignores = {} preview = false