- Formatter/Linter: Ruff (version pinned in
pyproject.toml) - Config:
pyproject.tomlunder[tool.ruff]
[tool.ruff]
line-length = 120
[tool.ruff.lint.pycodestyle]
max-line-length = 150- Target line length: 120 characters
- Hard limit (pycodestyle): 150 characters
[tool.ruff.lint]
preview = true
select = ["ALL"]All rules are enabled with preview mode. Specific categories and rules are then ignored:
Permanently ignored categories:
COM812— trailing comma (conflicts with formatter)CPY— copyright notices (handled manually)D— docstring conventions (pydocstyle)DOC— documentation warningsISC— implicit string concatenationFBT— boolean trap
Ignored for investigation:
PT(pytest style),PGH(pygrep-hooks),ERA(eradicate),SLF001(private member access),EM(error messages),TRY(tryceratops),TD/FIX(todos),TID(tidy imports),G(logging format),FLY(flynt),RSE(raise),BLE(blind exception),A(builtins shadowing)
Ignored for later reactivation:
B904,C408,E402,INP001,N806,PLC0415,PLR0912,PLR6201,PLR6301,PLR1702,PLR0913,RET504
[tool.ruff.lint.per-file-ignores]
"docs/**/*.py" = ["ALL"]
"plugins/**/*.py" = ["ANN201", "ANN202", "ANN204", "ANN401", "F404", "UP001", "UP010"]
"tasks/*.py" = ["T201"]- Plugin files skip some annotation and future-import rules (Ansible compatibility)
- Task files allow
print()calls - Doc generation skips all rules
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false- Double quotes for strings
- Spaces for indentation (not tabs)
- Preserve trailing commas
[tool.ruff.lint.isort]
known-first-party = ["infrahub"][tool.ruff.lint.mccabe]
max-complexity = 19# Check formatting and lint (CI-style, no changes)
invoke lint
# Auto-fix formatting and lint issues
invoke formatOr directly:
# Check
ruff format --check --diff .
ruff check --diff .
# Fix
ruff format .
ruff check --fix .- yamllint — YAML formatting (config:
.yamllint.yml) - ansible-lint — Ansible-specific linting (config:
.ansible-lint) - markdownlint — Markdown formatting (config:
.markdownlint.yml) - Vale — Documentation prose style (config:
.vale.ini)
python = ">=3.10,<3.14"Target Python 3.10+ but maintain the Ansible __future__ imports and __metaclass__ = type boilerplate for ansible-test sanity compliance.
Use modern type hints (str | None not Optional[str]). The from __future__ import annotations import is present in all files.
Managed via uv:
uv sync # Install all deps
uv sync --group dev # Include dev deps
uv add <package> # Add a dependency
uv add --group dev <package> # Add a dev dependency