checks.linting.LintingCheck
checks.linting.LintingCheck()Run linting tools on the package.
Executes a linting tool to check code quality and style. Supports ruff, flake8, and pylint, and by default runs the one the project has configured. A project that has configured none is skipped.
Attributes
name :-
The check identifier (“linting”).
description :-
Human-readable description of this check.
rules :-
The codes of the findings this check can report.
hints :-
What to do about each code.
SUPPORTED_TOOLS :-
List of supported linting tools.
Examples
Run the linter the project has configured:
>>> from pathlib import Path
>>> check = LintingCheck()
>>> result = check.run(Path("."), {"enabled": True})
>>> result.name
'linting'Run flake8, whatever the project has configured:
>>> config = {"enabled": True, "tool": "flake8"}
>>> result = check.run(Path("."), config)Pass additional ruff arguments:
>>> config = {"enabled": True, "tool": "ruff", "args": ["--select", "E,W"]}
>>> result = check.run(Path("."), config)Methods
| Name | Description |
|---|---|
| run | Run linting check on the package. |
run
checks.linting.LintingCheck.run(package_path, config)Run linting check on the package.
Executes the linting tool and collects any issues found. With tool = "auto" that is the linter the project has configured, and a project that has configured none is skipped. Issues are reported in the result details (the first MAX_DETAIL_LINES of them). The linter never modifies files.
Parameters
Returns
: CheckResult-
A CheckResult with:
: CheckResult-
- OK status if no linting issues found
: CheckResult-
- WARNING status if linting issues found, or if the linter is installed but could not run
: CheckResult-
- ERROR status if the linter times out or an unsupported tool or an invalid option is specified
: CheckResult-
- SKIPPED status if the project has configured no linter, the linting tool is not installed, or pyproject.toml could not be read and no other file configures a linter, which the metadata check reports (“prerequisite-failed”)