Correctly aggregate narrowing information on parent expressions#21206
Open
hauntsaninja wants to merge 3 commits intopython:masterfrom
Open
Correctly aggregate narrowing information on parent expressions#21206hauntsaninja wants to merge 3 commits intopython:masterfrom
hauntsaninja wants to merge 3 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: spark (https://github.com/apache/spark)
- python/pyspark/pandas/typedef/typehints.py:163: error: Item "str" of "str | type | dtype[Any] | ExtensionDtype" has no attribute "__args__" [union-attr]
- python/pyspark/pandas/typedef/typehints.py:163: error: Item "type" of "str | type | dtype[Any] | ExtensionDtype" has no attribute "__args__" [union-attr]
- python/pyspark/pandas/typedef/typehints.py:163: error: Item "dtype[Any]" of "str | type | dtype[Any] | ExtensionDtype" has no attribute "__args__" [union-attr]
- python/pyspark/pandas/typedef/typehints.py:163: error: Item "ExtensionDtype" of "str | type | dtype[Any] | ExtensionDtype" has no attribute "__args__" [union-attr]
altair (https://github.com/vega/altair)
- altair/vegalite/v6/api.py:5171: error: Item "UndefinedType" of "Any | Sequence[VariableParameter | TopLevelSelectionParameter | SelectionParameter] | UndefinedType" has no attribute "__iter__" (not iterable) [union-attr]
discord.py (https://github.com/Rapptz/discord.py)
- discord/channel.py:2192: error: Incompatible return value type (got "list[VoiceChannel | StageChannel | ForumChannel | TextChannel | CategoryChannel]", expected "list[TextChannel]") [return-value]
- discord/channel.py:2199: error: Incompatible return value type (got "list[VoiceChannel | StageChannel | ForumChannel | TextChannel | CategoryChannel]", expected "list[VoiceChannel]") [return-value]
- discord/channel.py:2209: error: Incompatible return value type (got "list[VoiceChannel | StageChannel | ForumChannel | TextChannel | CategoryChannel]", expected "list[StageChannel]") [return-value]
- discord/channel.py:2219: error: Incompatible return value type (got "list[VoiceChannel | StageChannel | ForumChannel | TextChannel | CategoryChannel]", expected "list[ForumChannel]") [return-value]
jax (https://github.com/google/jax)
+ jax/_src/interpreters/pxla.py:570: error: Unused "type: ignore" comment [unused-ignore]
|
ilevkivskyi
approved these changes
Apr 13, 2026
Member
ilevkivskyi
left a comment
There was a problem hiding this comment.
Thanks! This makes things much cleaner.
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.
Fixes #21204 , fixes #20596
The extra narrowing we perform in mypy 1.20 exposes this much longer standing issue