diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 00000000..bb0e8538 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,54 @@ +name: ruff + +on: + push: + branches: + - master + pull_request: + branches: + - master + +permissions: + contents: read + +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: 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: "check --output-format=github" + # https://docs.astral.sh/ruff/linter/ + - name: Show helpful safe production code fixes + uses: astral-sh/ruff-action@v3 + with: + src: pytm + version: "latest" + 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 --diff --unsafe-fixes --output-format=github" + continue-on-error: true diff --git a/pyproject.toml b/pyproject.toml index 56a5d28c..8db78490 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,3 +16,51 @@ 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 = [] +logger-objects = [] +per-file-ignores = {} +preview = false +select = ["E4", "E7", "E9", "F"] +task-tags = ["TODO", "FIXME", "XXX"] +typing-extensions = true +typing-modules = [] +unfixable = []