From 8b364b08874638b0f23a64d85a7bdde65a7f9a49 Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Fri, 30 May 2025 15:43:20 +0200 Subject: [PATCH] chore: Add pre-commit ruff config++ --- .gitlab-ci.yml | 2 +- .pre-commit-config.yaml | 2 -- bin/lint | 6 ------ bin/pre-commit | 3 +++ pyproject.toml | 24 ++++++++++++++++++++++++ 5 files changed, 28 insertions(+), 9 deletions(-) delete mode 100755 bin/lint create mode 100755 bin/pre-commit diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f56dcd..ed48c10 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ tests: lint: stage: test script: - - uv run bin/lint + - uv run bin/pre-commit deploy: stage: deploy diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be10ef3..cc1c8dc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,3 @@ -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: 'v0.11.7' diff --git a/bin/lint b/bin/lint deleted file mode 100755 index ecf3d76..0000000 --- a/bin/lint +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -SRC_DIR="bbs" - -black --check $SRC_DIR -isort --diff $SRC_DIR \ No newline at end of file diff --git a/bin/pre-commit b/bin/pre-commit new file mode 100755 index 0000000..19d5b62 --- /dev/null +++ b/bin/pre-commit @@ -0,0 +1,3 @@ +#!/bin/bash + +uvx pre-commit run --all-files diff --git a/pyproject.toml b/pyproject.toml index 9059df0..ef99973 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,3 +29,27 @@ dev = [ "pytest", ] +[tool.ruff] +line-length = 120 +target-version = "py310" + +[tool.ruff.lint] +select = ["ALL"] +ignore = [ + "D", # pydocstyle: Allow undocumented code + "ANN", # flake8-annotations: Allow untyped code + "TD", "FIX", # Allow TODOs and FIXMEs + "RUF012", # FIXME: Fix later https://docs.astral.sh/ruff/rules/mutable-class-default/ + "FBT002", # Allow boolean args + "G004", # Allow logging using f-string + "EM101", "EM102", # Allow string in exceptions (prioritice code readability vs exception time readability) + "TRY003", # Allow long exception messages + "E501", # Allow long lines + "COM812", "ISC001", # Avoid conflicting with ruff formatter +] + +[tool.ruff.lint.per-file-ignores] +# Testing code can deviate a bit more +"bbs/tests/*.py" = ["S101", "S106", "PLR2004"] +"**/test_*.py" = ["S101", "S106", "PLR2004"] +"**/tests.py" = ["S101", "S106", "PLR2004"]