Add comprehensive ruff linting rules and migrate to uv build backend

- Configure ruff with strict linting rules (pycodestyle, pyflakes, isort, pylint, etc.)
- Exclude notebooks folder from linting
- Set line length to 88 characters and target Python 3.13
- Migrate build backend from hatchling to uv_build for better integration
- Add per-file ignores for __init__.py and scripts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Deeman
2025-10-12 21:41:39 +02:00
parent ce1cad4c41
commit 7e06eae5ac

View File

@@ -48,7 +48,102 @@ members = [
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
requires = ["uv_build>=0.9.2,<0.10.0"]
build-backend = "uv_build"
[tool.ruff]
# Exclude notebooks and common directories
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
"notebooks",
]
# Set line length to match common Python style
line-length = 88
indent-width = 4
# Assume Python 3.13
target-version = "py313"
[tool.ruff.lint]
# Enable recommended rules plus additional useful ones
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"SIM", # flake8-simplify
"PL", # pylint
"RUF", # ruff-specific rules
]
# Ignore specific rules that may be too strict
ignore = [
"E501", # line too long (handled by formatter)
"PLR0913", # too many arguments to function call
"PLR2004", # magic value used in comparison
]
# Allow fix for all enabled rules (when `--fix` is provided)
fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.format]
# Use double quotes for strings
quote-style = "double"
# Indent with spaces, not tabs
indent-style = "space"
# Respect magic trailing comma
skip-magic-trailing-comma = false
# Automatically detect line ending
line-ending = "auto"
[tool.ruff.lint.isort]
# Combine as imports on the same line
combine-as-imports = true
# Use a single line for direct imports
force-single-line = false
[tool.ruff.lint.per-file-ignores]
# Allow unused imports in __init__.py files
"__init__.py" = ["F401"]
# Allow print statements and other rules in scripts
"scripts/*" = ["T201"]