refactor(python): add ty suppression codes to existing type: ignores#4639
Merged
Conversation
Five library lines carry intentional `# type: ignore[<code>]` comments
for Pyright (genuine, accepted gaps: a too-weak `SupportsInt` bound on
div_rem, the StringableBase duck-typed ToString, an intentional
FSharpArray.append LSP override, and an async map arg-type). Astral's
`ty` does not honour mypy/pyright rule codes, so it re-reported all of
them.
Append ty-prefixed suppressions as a separate trailing comment, e.g.
q = x // y # type: ignore[operator] # ty: ignore[unsupported-operator]
The separate-comment form is required: folding the ty code into the
same bracket (`# type: ignore[operator, ty:unsupported-operator]`)
breaks Pyright's bracket parser and de-suppresses the line. With two
comments, Pyright reads its bracket and ty reads `# ty: ignore[...]`.
Silences 7 false/intentional `ty` diagnostics (library 68 -> 61) with
no change to Pyright (0 library / 34 tests) and all 2350 Python tests
passing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five library lines carry intentional
# type: ignore[<code>]comments for Pyright — genuine, accepted typing gaps:int32.div_rem—///%on a deliberately weakSupportsIntbound (# type: ignore[operator])StringableBase.__str__/__repr__— duck-typedself.ToString()provided by subclasses (# type: ignore[attr-defined])FSharpArray.append— intentional LSP-incompatible override ofMutableSequence.append(# type: ignore[override])async_.parallel—map(...)arg-type (# type: ignore[arg-type])tydoes not honour mypy/pyright rule codes, so it re-reported all of these. This appends ty-prefixed suppressions as a separate trailing comment:Why the separate-comment form
Folding the ty code into the same bracket —
# type: ignore[operator, ty:unsupported-operator]— breaks Pyright's bracket parser (the:invalidates the whole comment) and de-suppresses the line. With two comments, Pyright reads its[...]bracket and ty reads# ty: ignore[...]. Verified against Pyright 1.1.407 and latest with the repo'sreportUnnecessaryTypeIgnoreComment: trueconfig.Verification
Silences 7 false/intentional
tydiagnostics with no change to Pyright and all 2350 Python tests passing. (Counts are relative to currentmain, i.e. after #4637 and #4638.)Context
Part of an investigation into whether
tycould eventually replace Pyright for this repo. Together with #4638 (FSharpRef overloads, −178) this brings ty from 364 → 179 total diagnostics. The remainder are genuinetysolver limitations (Option/SomeWrappertypevar widening, bidirectional generic specialization) best left untiltymatures.🤖 Generated with Claude Code