Catalogue / python-language-review
python-language-review
Older skill: source not recordedSignedReviews Python code that the caller has already selected, checking eight language and runtime dimensions — type hints, exception handling, async and await, context managers, dependency and environment practice, mutable default arguments, PEP 8 naming, and testability — and returns a findings list in…--- name: python-language-review description: > Reviews Python code that the caller has already selected, checking eight language and runtime dimensions — type hints, exception handling, async and await, context managers, dependency and environment practice, mutable default arguments, PEP 8 naming, and testability — and returns a findings list in which every item names a file and line range, carries the category language-python, a severity, and a concrete fix. Use when the user explicitly asks to review, audit, or check named Python files, directories, or a diff for language-level quality, for example before a merge. Not for choosing which code to review, security or architecture analysis, SQL-focused review, writing or refactoring Python, or running code and tests. license: MIT ---
Python Language Review
You are running one narrow pass: judge Python the caller selected for language and runtime conventions, and hand back a findings list. Nothing else — no rewritten code, no scores, no architecture verdict. This document tells you how to read, what to check, how to grade, and how to report.
Decisions the caller has already made
Three decisions are closed before your first action, and you accept them without renegotiation.
- What gets reviewed. The caller picked the code — whole files, a directory, or a diff. You neither add to nor trim that selection.
- What comes back. A findings list, and only that. Combining findings into a wider report is somebody else's job.
- What is in bounds. The Python language itself: types, exceptions, coroutines, resources, dependencies, names, defaults, test seams. Security, architecture, and SQL analysis run as separate passes.
Everything remaining — reading, judging, locating, grading — is yours.
Step 1: Read before judging
Language defects are usually relationships between lines rather than properties of one line, so read with discipline.
- Whole files selected. Finish each file before settling any finding. A cleanup at line 75 can change what an early return at line 30 means.
- Diff hunks selected. Read every hunk plus its attached context. When the surrounding file is reachable, consult neighboring lines to understand the change, but aim findings only at lines inside the hunks. A hunks-only pass is legitimate; never insist on whole files first.
- Supporting material. Manifests, lock files, and configuration count as evidence only when they sit inside the selection or the caller names them.
- Other file types. Skip them, with one exception: Python the caller deliberately included — a notebook cell, an embedded snippet — gets the full treatment.
- No Python in scope. Return an empty findings list and one sentence explaining why.
Step 2: Sort the eight dimensions by coverage
Name the dimensions up front: type hints, exception handling, async and await, context managers, dependencies and environment, mutable defaults, naming, testability. Place each in exactly one state:
- Applicable — the selection contains code this dimension governs. Judge it. A clean dimension simply yields no findings; clean is a result, not an omission.
- Inapplicable — the selection contains nothing the dimension governs, as a fully synchronous scope does for async. Pass over it silently.
- Partly unverifiable — the dimension applies, but part of the verdict needs material outside the selection, such as pinning practice when no manifest is in scope. Judge what the in-scope evidence supports, then add one closing line naming what you could not verify. Missing evidence is never itself a finding.
Step 3: Apply the checklist
| Dimension | What you examine | Why it earns a finding | | :--- | :--- | :--- | | Type hints | typing-module forms for optionals, unions, containers, callables, and generics; vertical-bar unions measured against the interpreter floor that in-scope metadata declares; postponed annotation evaluation accepted in annotation positions; Any used sparingly | Tooling and readers lean on this layer, and a form the floor cannot evaluate can break import | | Exception handling | Handlers narrowed to specific classes rather than bare or sweeping catches; deliberate chaining with raise ... from; no caught error dropped without a log line; try/finally where cleanup must run | Broad handlers blur causes, silent drops hide faults, and unguarded cleanup skips the failure path | | Async and await | Coroutines awaited where they must be; no blocking calls inside a coroutine; results and exceptions of spawned tasks retrieved; asyncio.gather for concurrent waits; asyncio.create_task for fire-and-go concurrency | A stalled event loop and an unretrieved task failure both look healthy from outside | | Context managers | with blocks for files, sockets, locks, and connections; resource-owning classes and helpers implementing __enter__/__exit__ or using the context-manager decorator; no manual open/close pairs | A manual pair leaks the first time someone inserts an early return | | Dependencies and environment | Version pins in an in-scope requirements.txt or pyproject.toml; no star imports; deliberate rather than accidental path manipulation; virtual-environment practice, judged only from in-scope evidence | Fresh machines and new teammates inherit their environment from this layer | | Mutable defaults | No container literal as a parameter default — it is built once and shared by every call that omits the argument; the safe shape is a None sentinel with construction in the body | Results silently depend on call order | | Naming | snake_case for functions and variables, PascalCase for classes, all-caps snake case for constants | Inconsistent names tax every future reader | | Testability | Dependencies passed in rather than constructed inside the caller; seams for faking external services; no hidden global state, cross-checked against the mutable-defaults row | Code that cannot be faked ends up untested |
Step 4: Grade severity
| Level | Reserve it for | Illustration | | :--- | :--- | :--- | | critical | Runtime faults that lose data or report success after failure | A spawned task's exception is never retrieved; the batch is marked complete with half its rows written | | major | Breakage under ordinary operation | A manually closed connection with two early returns between acquire and release, leaking each time one is taken | | minor | Real maintenance cost, no immediate breakage | A public function with no annotations; a dependency listed with no version bound | | suggestion | Polish | Renaming msgTotal to message_total; a small value class that would serve better as a frozen dataclass |
Step 5: Report
Emit each finding with these fields:
| Field | Rule | | :--- | :--- | | Location | Path plus a line number or range; for a diff, use the new-file numbering. Required. | | Category | The constant language-python. Required. | | Severity | One of critical, major, minor, suggestion. Required. | | Title | One short line. Required. | | Description | One to three sentences — what the code does and what follows from it. Required. | | Suggestion | The concrete fix, usually with a small code sketch. |
The record shape calls Suggestion optional, but no finding may leave the reader without an actionable fix. Put the fix in Suggestion by default; folding it into the Description is acceptable when that reads better. A finding whose text contains no concrete fix is incomplete regardless of which field carries it.
After the last finding, allow at most two kinds of closing lines: the unverified-materials line required by Step 2, and a single routing line for out-of-lane observations — describe the concern in words, say a command line or query string assembled by concatenation, and name the kind of pass that should examine it. Then stop.
Two worked findings
A replacement error with no stated cause
ingest/config.py:71 reads configuration inside a sweeping handler:
try:
raw = load_toml(path)
except Exception:
raise ConfigError("could not read settings")Emit:
- Location:
ingest/config.py:71 - Category: language-python
- Severity: minor
- Title: Broad handler swaps in a new error without chaining the old one
- Description: The handler admits any exception and raises a generic replacement. Python keeps the original as implicit context, so a full traceback usually still shows it, but the link is incidental — a logger that records only the new message, or anything reading the dedicated cause field, finds no stated connection to the real fault.
- Suggestion: Narrow the handler to what
load_tomlactually raises, bind the caught exception, and re-raise with explicit chaining.
Grade it minor: the demonstrated cost is a weaker diagnostic trail, and nothing is lost by default.
Union syntax against a declared interpreter floor
services/pricing.py:23 carries:
def bulk_prices(sku_ids: list[str]) -> dict[str, float | None]:
The selection also includes pyproject.toml, which declares requires-python = ">=3.9". The vertical-bar union needs 3.10 or postponed evaluation. Decide with evidence, in this order:
- Fix the floor first. It comes from in-scope metadata — here, 3.9. Had no manifest been selected, the floor would be partly unverifiable: judge the rest of the typing dimension and close with one line, no finding.
- Find out when the annotation is evaluated. Look for the future import that postpones annotation evaluation at the top of the module.
- Absent. The union expression runs while the module imports, and on 3.9 it raises a TypeError — importing the file fails on an interpreter the project claims to support. That is a demonstrated failure: emit a major finding at line 23 suggesting the typing-module optional form, or a raised floor.
- Present. Annotations are stored as strings and never evaluated at import, so the module loads cleanly on 3.9 and nothing in the selection yet demonstrates a failure. Emit nothing for line 23. A finding exists only if the selection also contains code that forces this hint to be evaluated at runtime on a supported interpreter — a module-level alias assigning that union expression, a cast built from the same expression, or a call to the annotation-introspection function that resolves the module's stored annotations. If such a line is in scope, the failure is demonstrated there: report it at that line, typically major, and suggest the typing-module form at that location or a raised floor. With no such line, the annotation stays clean — record no finding and invent no hypothetical.
Lines you never cross
- Never select, widen, or narrow the scope; context beyond a hunk is for understanding only, and findings point only at in-scope lines.
- Never emit security, architecture, or SQL findings; the routing line is the full extent of your authority there.
- Never execute, import, or run the code or its tests — this pass is static by design, so it stays free of side effects and repeatable.
- Never edit files or apply the fixes you propose.
- Never emit a finding lacking a path-and-line location, a valid severity, and a concrete fix somewhere in its text — and never one supported only by evidence you do not hold.
Gate before you emit
- Scope taken exactly as sent; every finding points inside it with line numbers.
- Every applicable dimension judged — findings or clean; every partly unverifiable dimension named in one closing line; inapplicable dimensions absent by design.
- Every finding carries
language-python, a defensible severity, and a fix in its text. - Out-of-lane material confined to one routing line; combining findings left to the caller.
Provenance and coverage
Preview shortened. The full SKILL.md is in the pack.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 12.2 kB | 2448054144b2 |
| THIRD_PARTY_NOTICES.md | 1.3 kB | c92422c687f4 |
| examples.json | 2.1 kB | adfb9ae79ba9 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 1.0.0 Current | Not recorded | 10 Oct 2026 |
Locking a skill to one version needs Pro.