Reading — step 1 of 5
Read
~1 min readConfiguration & Output
Configuration Files
Linters read config from files in priority order:
- CLI flags (
--max-line-length=120). pyproject.toml[tool.linter]section (modern).- Legacy
.flake8,.pylintrcfiles. - Defaults.
Config controls:
- Enabled rules:
enable = [E501, W292]ordisable = [...]. - Severity per rule:
error / warning / info. - Per-rule options:
max-line-length=100,max-complexity=15. - Per-file overrides:
[per-file-ignores]tests/*.py = E501.
Example pyproject.toml:
[tool.ruff]
line-length = 100
select = ["E", "F", "W", "B"]
ignore = ["E501"]
[tool.ruff.per-file-ignores]
"tests/**" = ["S101"] # allow assert in tests
Loading:
python
Inheritance: nested directories can have own config files (extend = "../base.toml"). Settings merge top-down.
Make config-driven choices first-class:
- Don't hardcode "max line 79". Let users override.
- Don't ship rules enabled by default that users will spend hours suppressing.
- Document each rule's purpose + how to fix.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…