Catalogue / ruff-ty-python-gates
ruff-ty-python-gates
Older skill: source not recordedSignedSets up and runs Python quality gates with Ruff for linting and formatting and ty for type checking: CLI commands, pyproject.toml policy, modern type annotations, pre-commit hooks and CI checks. Use when the user mentions "run ruff", "fix lint errors", "add type checking", "set up pre-commit", or wa…--- name: ruff-ty-python-gates description: >- Sets up and runs Python quality gates with Ruff for linting and formatting and ty for type checking: CLI commands, pyproject.toml policy, modern type annotations, pre-commit hooks and CI checks. Use when the user mentions "run ruff", "fix lint errors", "add type checking", "set up pre-commit", or wants Python code-style enforcement in CI. Not for writing tests, security auditing, or runtime performance profiling. ---
Ruff and ty Quality Gates
Diagnose first, mutate second: report findings, agree on fixes with the user, then write. Installing packages, syncing environments and starting watchers each need separate approval — some runners fetch tools implicitly.
Read the project before running anything
- Inspect
pyproject.toml, the lockfile, source layout and existing hooks. - Check what is installed:
ruff --version,ty --versionand each
tool's --help. Missing tooling is a reported limitation, not a reason to download it unprompted.
- Target the lowest Python version the project supports, not the
interpreter that happens to be active.
Command reference
| Goal | Command | Note | | --- | --- | --- | | Lint | ruff check . | Report before fixing | | One rule | ruff check --select E501 . | Inspect without changing policy | | Silence a rule temporarily | ruff check --ignore E501 . | Explain what it hid | | Auto-fix | ruff check --fix . | Approval + diff review | | Format check | ruff format --check . | No files written | | Format write | ruff format . | Separate approval from fixes | | Watch | ruff check --watch . | Long-running; stop it after use | | Type check project | ty check | Configured scope | | Type check one file/dir | ty check src/catalog.py | Verify the CLI accepts the argument | | Verbose / CI output | ty check --verbose / --hide-progress | Confirm the flag exists in the installed version |
In an approved uv environment the same commands run as uv run ruff ... and uv run ty ... (mind its sync behavior). uv add --dev ruff ty changes the project — propose it, don't just run it. Never chain --fix and format without approval covering both.
Lint and format policy in pyproject.toml
Merge into the existing TOML; never replace the file or duplicate tables:
[tool.ruff] target-version = "py312" line-length = 100 src = ["src", "tests"] [tool.ruff.lint] select = ["E", "W", "F", "I", "N", "UP", "B"] ignore = ["E501"] [tool.ruff.lint.isort] known-first-party = ["catalog_service"] [tool.ruff.format] quote-style = "double" indent-style = "space"
- Rule families:
E/Wpycodestyle,Fpyflakes,Iimport order,
N naming, UP modern syntax, B bug-prone patterns.
- Ignoring
E501accepts lines the formatter cannot shorten; raise it as
an explicit team decision rather than a default.
- Common findings: F401 unused import, F841 unused local, I001 unsorted
imports, N806 non-lowercase local, B008 call in a default. Read the semantics first — removing an import can drop an intentional side effect; skip unsafe fixes unless understood and approved.
Type checking with ty
ty's configuration schema and diagnostic names vary by release — validate against the installed version's help/schema; a TOML file that parses is not a schema that is accepted.
- Pin the interpreter version via ty's actual supported option.
- Exclude bytecode caches and virtual environments through its real
scope mechanism; decide deliberately whether tests/ is checked.
- Treat
possibly-unboundas a warning only if that diagnostic exists
and the team accepts the risk; record why it is not an error.
Modern annotations
from typing import TypeAlias
ShelfId: TypeAlias = int
CatalogRecord: TypeAlias = dict[str, str | int]
def summarize_titles(
titles: list[str],
limits: dict[str, int],
label: str | None = None,
) -> tuple[bool, str]:
maximum = limits.get("maximum", 0)
if maximum < 1 or not titles:
return False, "No usable title selection"
heading = label if label is not None else "Selected titles"
return True, f"{heading}: {', '.join(titles[:maximum])}"
def catalog_record(shelf_id: ShelfId) -> CatalogRecord:
return {"shelf_id": shelf_id, "section": "Local history"}Prefer list[str], dict[str, int], X | None over List, Dict, Optional on 3.10+. Hints do not validate untrusted input at runtime — keep runtime checks where behavior depends on them.
Hooks and CI
- Before choosing hook IDs and revisions, read the actual hook repository
manifest; IDs differ between Ruff pre-commit releases.
- If
--fixruns in a hook, warn that committing can rewrite the working
tree and the user must inspect and re-stage.
- Verify a remote ty hook actually exists at the pinned revision; a
reviewed local hook invoking the locked checker is a valid fallback.
- CI: run lint,
format --checkand type check in a pinned environment,
no auto-fixes, explicit exit-status handling. Keep project-wide type checks whole-project; file filtering is not equivalent analysis.
Deliver: findings, proposed config, tool versions, checked scope, the approved diff, and check evidence. Name anything unvalidated.
Never
- Install packages, sync environments, or start watchers without approval for that specific action.
- Assume config keys, hook IDs or diagnostic names from one tool release apply to another.
- Apply
--fixor formatting blindly, or suppress a rule without a stated reason. - Claim that lint, format or type checks prove runtime behavior or security.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 5.6 kB | e7a25672ebdb |
| examples.json | 1.6 kB | e7fb34ab4d33 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 1.0.1 Current | Not recorded | 6 Oct 2026 | |
| 1.0.0 | Not recorded | 3 Oct 2026 |
Locking a skill to one version needs Pro.