Commit 62053f77 authored by Jan Reimes's avatar Jan Reimes
Browse files

feat(config): add ruff and ty configuration files

- Introduced ruff.toml for linting configuration
- Added ty.toml for type checker rules
- Updated dependencies in pyproject.toml for improved code quality
parent 9b1c03d4
Loading
Loading
Loading
Loading
+16 −55
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ dev = [
    "pytest-asyncio>=1.2.0",
    "mdformat>=1.0.0",
    "rust-just>=1.46.0",
    "isort>=7.0.0",
    "undersort>=0.1.5",
]

[build-system]
@@ -58,65 +60,10 @@ build-backend = "uv_build"
[project.scripts]
tdoc-crawler = "tdoc_crawler.cli:app"

[tool.ty.environment]
python = "./.venv"
python-version = "3.14"

[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["src"]

[tool.ruff]
target-version = "py314"
line-length = 160
fix = true

[tool.ruff.lint]
select = [
    # flake8-2020
    "YTT",
    # flake8-bandit
    "S",
    # flake8-bugbear
    "B",
    # flake8-builtins
    "A",
    # flake8-comprehensions
    "C4",
    # flake8-debugger
    "T10",
    # flake8-simplify
    "SIM",
    # isort
    "I",
    # mccabe
    "C90",
    # pycodestyle
    "E", "W",
    # pyflakes
    "F",
    # pygrep-hooks
    "PGH",
    # pyupgrade
    "UP",
    # ruff
    "RUF",
    # tryceratops
    "TRY",
]
ignore = [
    # LineTooLong
    "E501",
    # DoNotAssignLambda
    "E731",
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"]
"**/cli.py" = ["B008"]  # typer.Option/Argument in function defaults is intentional

[tool.ruff.format]
preview = true

[tool.coverage.report]
skip_empty = true
@@ -124,3 +71,17 @@ skip_empty = true
[tool.coverage.run]
branch = true
source = ["src"]

[tool.undersort]
# Method visibility ordering: public (no underscore), protected (single underscore), private (double underscore)
# Customize the order by specifying: "public", "protected", "private"
order = ["public", "protected", "private"]

# Method type ordering within each visibility level (optional)
# Options: "class" (classmethod), "static" (staticmethod), "instance" (regular methods)
# Default order if not specified: ["instance", "class", "static"]
method_type_order = ["instance", "class", "static"]

# Exclude files/directories matching these patterns (optional)
# Patterns support glob syntax (e.g., "tests/*", "migrations/*.py", "**/generated/*")
# exclude = ["tests/*", "migrations/*.py"]

ruff.toml

0 → 100644
+71 −0
Original line number Diff line number Diff line

unsafe-fixes = true
exclude = [".venv"]
target-version = "py314"
line-length = 160
fix = true

[lint]
preview = true
explicit-preview-rules = true
select = [
    # Default rules
    "E",     # pycodestyle errors
    "F",     # Pyflakes
    "C4",    # flake8-comprehensions
    "C90",   # mccabe complex structure
    "D",     # pydocstyle
    "I",     # isort
    "PT",    # flake8-pytest-style
    "PL",    # Pylint
    "SIM",   # flake8-simplify
    "UP",    # pyupgrade
    "W",     # pycodestyle warnings
    "S",     # flake8-bandit
    "ANN",   # flake8-annotations
    "B",     # flake8-bugbear
    "NPY",   # NumPy-specific rules
    "UP045",
]
extend-select = [
    "RUF022",  # unsorted-dunder-all
    "PLR6301", # no-self-use
    "PLC0415",
    "E402",    # module-import-not-at-top-of-file
]
ignore = [
    "B024",
    "B028",    # no-explicit-stacklevel
    "B904",
    "C901",    # complex-structure
    "D100",
    "D101",
    "D102",
    "D103",
    "D104",
    "D105",
    "D107",
    "D415",
    "D200",
    "D205",
    "D212",
    "E722",
    "ANN002",
    "ANN003",
    "ANN204",  # dynamically typed typed expressions
    "ANN401",
    "PLR0912",  # too-many-branches
    "PLR0913",
    "PLR2004", # magic value used in comparison
    "PT028",   # test function parameter has default argument
]

[lint.pylint]
max-locals = 20

[lint.pydocstyle]
convention = "google"

[format]
docstring-code-format = true
docstring-code-line-length = 160
 No newline at end of file

ty.toml

0 → 100644
+14 −0
Original line number Diff line number Diff line
# type checker rules - see https://docs.astral.sh/ty/reference/rules/

[environment]
python-version = "3.14"
python = "./.venv"

[src]
include = [
    "src",
    "tests",
]

[terminal]
error-on-warning = true