Python linting and formatting with Ruff
Inspect pyproject.toml or ruff.toml and the existing verification commands. In a uv project
with Ruff declared, use uv run ruff; for locked verification use uv run --frozen ruff from
the manifest directory. Read uv for environment selection. Preserve another
chosen toolchain unless migration is within scope.
- Run
ruff check <scope>andruff format --check <scope>to understand the baseline. - Preview lint changes with
ruff check --diff <scope>. Apply appropriate fixes withruff check --fix <scope>before formatting. - Preview formatting with
ruff format --diff <scope>, then format the authorized scope. Broad formatting is appropriate when explicitly requested or already enforced by the project; otherwise keep unrelated files out of the diff. - Run the checks again and the behavioral tests affected by the edits. Formatting and lint success do not establish runtime correctness.
Keep the repository's configured rule sets and Python target. Do not blanket-disable checks to get a green result. Unsafe fixes can change behavior: read the rule explanation and inspect the proposed diff before applying an individual unsafe fix. Preserve import side effects and intentional failing fixtures; treat vendored snapshots and historical evidence as immutable.
Ruff owns lint and format, ty owns typing, and project tests plus projectctl own behavioral verification. Reuse existing results rather than requiring duplicate check runs. Respect native Kiro planning modes and current write permissions.
Reference: Ruff documentation.