I am using Ruff, a formatter or linter tool for Python code.
I want to ignore some specific rules, and to write that config in pyproject.toml
.
My package structure is as follows.
.
├── LICENSE
├── pyproject.toml
├── README.md
├── src
│ └── mypackage/mymodule.py
└── tests
├── doc.md
└── test_mymodule.py
And, I want to ignore rules pydocstyle (D) in the tests/
directory.
You can use Ruff's per-file-ignores and specify individual files, or select a directory tree with a wildcard (star). You can ignore a "letter class" by specifying only the letter.
To ignore line-length violations in your tests, add this to pyproject.toml:
[tool.ruff.lint.per-file-ignores]
"foofile.py" = ["E501"]
To ignore all pydocstyle errors (starting with "D") in your tests, add this to pyproject.toml:
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["D"]
The related Ruff docs are here.