| name | python-quality-install |
| description | Use when initializing a new Python project or adding quality tooling to an existing one - sets up ruff linter and formatter, pyright type checker, and pre-commit hooks with opinionated defaults that enforce python-quality-developer standards |
| metadata | {"category":"language-helpers"} |
Python Quality Install
Set up ruff, pyright, and pre-commit in a Python project. Run as /python-quality-install.
What It Does
- Adds ruff + pyright config to
pyproject.toml
- Creates
pyrightconfig.json
- Creates
.pre-commit-config.yaml
- Adds dev dependencies
- Installs and runs initial lint fix + format pass
- Verifies zero violations
Steps
1. Add ruff config to pyproject.toml
Append to pyproject.toml (merge if sections exist):
[tool.ruff]
target-version = "py310"
line-length = 120
src = ["src"]
[tool.ruff.lint]
select = [
"E",
"W",
"F",
"I",
"UP",
"B",
"S",
"T20",
"SIM",
"RUF",
]
ignore = [
"E501",
]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["S101", "S106", "S108", "S110", "RUF006"]
Adjust src and per-file-ignores for the project layout. If there's prototype/research code with print(), add "T201" ignore for those paths.
2. Create pyrightconfig.json
{
"include": ["src"],
"pythonVersion": "3.10",
"typeCheckingMode": "basic",
"reportMissingTypeStubs": false,
"reportUnknownMemberType": false,
"reportUnknownParameterType": false,
"reportUnknownVariableType": false,
"reportUnknownArgumentType": false
}
Start with basic mode. Upgrade to standard once the codebase is clean. strict requires typing every SDK boundary which is impractical for most projects.
3. Create .pre-commit-config.yaml
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.11
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
4. Add dev dependencies
Add to [project.optional-dependencies] in pyproject.toml:
[project.optional-dependencies]
dev = [
"ruff>=0.8",
"pyright>=1.1",
"pre-commit>=3.0",
]
5. Install and run
pip install -e ".[dev]"
pre-commit install
ruff check src/ tests/ --fix
ruff check src/ tests/ --fix --unsafe-fixes
ruff format src/ tests/
ruff check src/ tests/
pyright src/
6. Fix remaining violations
After auto-fix, common manual fixes needed:
| Violation | Fix |
|---|
B904 raise-without-from | Add from exc to re-raises in except blocks |
S110 try-except-pass | Use contextlib.suppress or add # noqa: S110 with comment |
F821 undefined-name | Missing import (often Any, Path) removed by auto-fix |
SIM102 collapsible-if | Combine nested if with and |
T201 print found | Replace with logging or add per-file ignore |
7. Verify
ruff check src/ tests/
ruff format --check src/ tests/
pyright src/
pytest tests/ -v
When to Use
- Starting a new Python project
- Inheriting a project with no quality tooling
- After
/python-quality-install, the python-quality-developer skill enforces ongoing compliance
Companion Skill
REQUIRED: python-quality-developer defines the coding standards that this tooling enforces. Install the tooling, follow the standards.