Skip to content

python: replace mypy with ty across lang/python and generated bindings - #64

Open
danepitkin wants to merge 11 commits into
mainfrom
worktree-python-ty
Open

danepitkin wants to merge 11 commits into
mainfrom
worktree-python-ty

Conversation

@danepitkin

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces mypy with ty as the Python type checker throughout lang/python/ (handbook, rules, examples, agents, commands, skills) and the shared passthrough/repo-root docs.
  • Regenerates the generated bindings (python-linter-driven-development/, coding-rules/python.md) from the updated sources.
  • Fixes follow-up review issues: correct ty invocation form, accurate command/behavior claims, and detection of both # type: ignore and # ty: ignore suppression comments.

Test plan

  • task generate BINDING=python run and committed alongside source changes
  • task check (drift check between sources and generated output)

- mechanics.md: replace mypy with ty and [tool.mypy] with [tool.ty]
- house-rules.md (P5): replace "mypy passes" with "ty passes"
- R1/example.md: replace "checked by mypy" with "checked by ty" and update # type: ignore syntax
- H1/spelling.md: replace all instances of # type: ignore with # ty: ignore syntax, update [tool.mypy] to [tool.ty], and soften PGH003 claim to "loses its rule name"
… ignore

Apply Rule B unconditionally across all files touched: bare # type: ignore → # ty: ignore.
…/python/examples/**

Swaps the type-checker name from mypy to Astral's ty across rule
falsifying-questions/canonical-example prose and the example write-ups
that narrate them, converting diagnostic codes and ignore-comment
syntax per the same mapping (arg-type -> invalid-argument-type,
return-value -> invalid-return-type, # type: ignore -> # ty: ignore).
…comment-critic/**

Apply Rule A (bare tool name) and Rule B (diagnostic/config mapping):
- hard-limits.md: # type: ignore → # ty: ignore; [tool.mypy]/mypy.ini → [tool.ty]/ty.toml
- routing-table.md: mypy return-value → ty invalid-return-type; mypy arg-type → ty invalid-argument-type
- mechanical-issues.md: mypy arg-type/assignment → ty invalid-argument-type/invalid-assignment; # type: ignore → # ty: ignore
- directives.md: # type: ignore → # ty: ignore
Swap the type-checker naming in the Python LDD skill prose from mypy to
Astral's ty, following the same noun-vs-invocation and diagnostic/config
mapping rules used elsewhere in this migration: bare `ty` when naming the
tool, `ty check` for actual invocations, `[tool.ty]`/`ty.toml` for config,
and renamed diagnostic codes (arg-type -> invalid-argument-type, etc.) and
`# ty: ignore` suppressions.
Swaps the type-checker name from mypy to Astral's ty in the Python
plugin's passthrough README/plugin.json/CHANGELOG, the repo-root
README and marketplace.json, and docs/language-residue.md — noun
mentions become ty, invocation-gated mentions become ty check,
[tool.mypy]/mypy.ini become [tool.ty]/ty.toml, and # type: ignore
becomes # ty: ignore with mapped diagnostic codes. Historical
CHANGELOG entries for 0.1.0/0.2.0 are left untouched since they
truthfully describe releases that shipped with mypy; a new
[Unreleased] bullet announces the swap.
Line ~235's tool-chain sentence lists literal invocation forms
(pytest, ruff check, ruff format), so ty belongs there as ty check,
same as the sibling sentence in passthrough/README.md. The prior
commit deferred to the brief's per-line "noun/config swap" label for
this line instead of applying Rule A's invocation criterion to the
sentence's actual structure; review correctly ruled the general
substitution rule takes precedence.
…s/python.md for mypy→ty

Regenerates the Python plugin's derived output (task generate BINDING=python)
to pick up the mypy→ty swap made across lang/python/** and passthrough/** in
prior tasks. task check, the mypy/type-ignore residue greps, and the
generator's own drift check all pass.
Finding 1: mechanics.md's Type check row is command-shaped like its
table neighbors, so it should show the literal `ty check` invocation,
not the bare noun `ty`.

Finding 2: the CHANGELOG's [Unreleased] bullet claimed a bare `ty check`
with no targets fails like mypy does. It doesn't — ty checks the whole
project from the pyproject.toml directory when given no paths. Drop the
false claim, keep the still-true [tool.ty] gating language.

Regenerated python-linter-driven-development/** and coding-rules/python.md
via `task generate BINDING=python`; `task check` reports zero drift.
ty honors the standard PEP 484 `# type: ignore` comment as a suppression
in addition to its own `# ty: ignore[<rule>]` syntax, unless explicitly
disabled. A prior mechanical mypy->ty pass over-narrowed several
detection/prohibition texts to only name `# ty: ignore`, which would miss
a legacy `# type: ignore` a ty-using repo can legitimately still carry.

Broaden the five detection/prohibition spots (lint-fixer hard limits,
comment-critic's directive skip-list, R3's block-comment detection grep,
pre-commit-review's in-context suppression check, and refactoring's
nolint prohibition text + its executable grep) to name both spellings.
Recommendation/example text that illustrates the `# ty: ignore` convention
is left untouched, per the review's guidance.

Verified the broadened grep `# *(noqa|(ty|type): *ignore)` against
`# noqa: E501`, `# ty: ignore[invalid-return-type]`, bare `# ty: ignore`,
`# type: ignore[assignment]`, and bare `# type: ignore` — all five match.

Regenerated python-linter-driven-development/** via
`task generate BINDING=python`; `task check` reports zero drift.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant