4.3 KiB
4.3 KiB
name, description, argument-hint, x-personal-mcp
| name | description | argument-hint | x-personal-mcp | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| python-typing | Reference-first skill for reviewing and modernizing Python typing to the newest supported best practices. Use when auditing annotations, replacing legacy typing syntax, and enforcing latest-syntax-first conventions. | Which files or package should be reviewed, and what Python baseline must be preserved? |
|
Modern Python Typing Review Reference
Use this skill to enforce a latest-syntax-first typing standard grounded in current Python language guidance.
Load references only when needed:
- Source map and standards links: typing source map
- Practical review workflow and quality gates: typing review workflow
- Astral ty adoption and operation guidance: Astral ty usage reference
When to Use
- A codebase still uses legacy
typingpatterns and should be updated to modern syntax. - You need a repeatable process for type-focused code review across a package or module.
- You want references to official Python docs and PEPs attached to recommendations.
- You need to decide whether a modern feature is allowed under the project Python version.
How To Use This Skill
- Confirm the effective Python baseline from project config (for example
pyproject.tomland lint target version). - Scan target files for legacy patterns and prioritize newest canonical syntax first.
- Apply modern typing upgrades aggressively, keeping runtime behavior stable unless explicitly requested otherwise.
- Validate with project lint and diagnostics.
- Report what changed and list only hard-blocker deferrals (for example incompatible Python baseline).
Intent Router
- Baseline and compatibility checks: typing source map
- Exact modernization sequence and branching logic: typing review workflow
- Integrating or tuning Astral ty: Astral ty usage reference
- Need official rationale for a specific feature: typing source map
Load Order
- Start with typing source map for authoritative links.
- Load typing review workflow to execute the review.
- Load Astral ty usage reference when the workflow includes
tysetup, configuration, migration, or editor integration. - Return to source links for any feature-level recommendation included in the final output.
Load Budget
- Default: load one reference (
index.md) for lightweight guidance. - Standard review: load two references (
index.mdandreview-workflow.md). - Add
astral-ty.mdonly whentyis in scope. - Do not load additional docs unless a project-specific edge case requires it.
Decision Baseline
Use these defaults unless a hard compatibility constraint prevents them:
- Prefer built-in generics (
list[str],dict[str, int]) overtyping.Listandtyping.Dict. - Prefer
X | Yovertyping.Optional[X]ortyping.Union[X, Y]. - Prefer PEP 695 generics (
class Box[T],def fn[T](...)) for Python 3.12+ codebases and use them by default. - Prefer
typing.Selffor fluent instance/class method return typing. - Use
typing.Literalwhen a finite value set is the real contract. - Remove legacy typing aliases and module-level
TypeVardeclarations when PEP 695 can replace them. - Keep runtime behavior unchanged unless the task explicitly requests behavior refactors.
Completion Checks
- Modern syntax aligns with the project Python baseline.
- Linting and diagnostics are clean for edited files.
- Public APIs are unchanged unless explicitly requested.
- Feature-level recommendations include source links.
- Any deferral is backed by a specific hard constraint (for example Python version floor).
Output Contract
Return:
- Files reviewed and files changed.
- Applied typing upgrades with brief rationale.
- Deferred upgrades only when blocked by explicit hard constraints.
- Validation results (lint/tests/diagnostics).
- References consulted and discovery path used.