fix Iterating over enumerated tuple loses typing information #1323#4090
Open
asukaminato0721 wants to merge 1 commit into
Open
fix Iterating over enumerated tuple loses typing information #1323#4090asukaminato0721 wants to merge 1 commit into
asukaminato0721 wants to merge 1 commit into
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: rotki (https://github.com/rotki/rotki)
- ERROR rotkehlchen/externalapis/cryptocompare.py:495:41-48: Argument `Price | Unknown` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR rotkehlchen/externalapis/cryptocompare.py:495:41-48: Type `Price` is not iterable [not-iterable]
bokeh (https://github.com/bokeh/bokeh)
- ERROR src/bokeh/layouts.py:307:34-37: Argument `UIElement | list[UIElement | None] | None` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR src/bokeh/layouts.py:307:34-37: Type `UIElement` is not iterable [not-iterable]
+ ERROR src/bokeh/layouts.py:307:34-37: Type `None` is not iterable [not-iterable]
spark (https://github.com/apache/spark)
- ERROR python/pyspark/pandas/frame.py:7176:45-57: Argument `list[Unknown] | tuple[Unknown | None] | Unknown | None` is not assignable to parameter `iterable` with type `Iterable[Unknown | None]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR python/pyspark/pandas/frame.py:7176:45-57: Type `None` is not iterable [not-iterable]
cwltool (https://github.com/common-workflow-language/cwltool)
- ERROR cwltool/command_line_tool.py:1251:46-56: Argument `MutableMapping[str, CWLOutputType | None] | MutableSequence[CWLOutputType | None] | bool | float | int | str | CWLDirectoryType | CWLFileType | None` is not assignable to parameter `inputid` with type `str` in function `cwltool.process.shortname` [bad-argument-type]
+ ERROR cwltool/command_line_tool.py:1251:46-56: Argument `MutableMapping[str, CWLOutputType | None] | MutableSequence[CWLOutputType | None] | bool | float | int | str | CWLDirectoryType | CWLFileType | Unknown | None` is not assignable to parameter `inputid` with type `str` in function `cwltool.process.shortname` [bad-argument-type]
pwndbg (https://github.com/pwndbg/pwndbg)
- ERROR pwndbg/commands/plist.py:418:33-42: Argument `list[int] | None` is not assignable to parameter `iterable` with type `Iterable[int]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR pwndbg/commands/plist.py:418:33-42: Type `None` is not iterable [not-iterable]
apprise (https://github.com/caronc/apprise)
- ERROR apprise/plugins/sns.py:805:44-49: Argument `str | Any` is not assignable to parameter `object` with type `LiteralString` in function `list.append` [bad-argument-type]
+ ERROR apprise/plugins/sns.py:805:44-49: Argument `str | Unknown` is not assignable to parameter `object` with type `LiteralString` in function `list.append` [bad-argument-type]
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- ERROR pymongo/asynchronous/cursor.py:915:56-57: Argument `Iterable[Unknown] | SupportsItems[Unknown, Unknown]` is not assignable to parameter `iterable` with type `Iterable[Unknown]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR pymongo/asynchronous/cursor.py:915:56-57: Type `SupportsItems[Unknown, Unknown]` is not iterable [not-iterable]
- ERROR pymongo/synchronous/cursor.py:913:56-57: Argument `Iterable[Unknown] | SupportsItems[Unknown, Unknown]` is not assignable to parameter `iterable` with type `Iterable[Unknown]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR pymongo/synchronous/cursor.py:913:56-57: Type `SupportsItems[Unknown, Unknown]` is not iterable [not-iterable]
ibis (https://github.com/ibis-project/ibis)
- ERROR ibis/expr/schema.py:83:44-54: Argument `Attribute` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR ibis/expr/schema.py:83:44-54: Type `Attribute` is not iterable [not-iterable]
strawberry (https://github.com/strawberry-graphql/strawberry)
- ERROR strawberry/experimental/pydantic/conversion.py:47:38-42: Argument `Unknown | None` is not assignable to parameter `iterable` with type `Iterable[Unknown]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR strawberry/experimental/pydantic/conversion.py:47:38-42: Type `None` is not iterable [not-iterable]
sockeye (https://github.com/awslabs/sockeye)
- ERROR sockeye/checkpoint_decoder.py:166:83-89: Argument `tuple[Any, ...]` is not assignable to parameter `strings` with type `list[str]` in function `sockeye.inference.make_input_from_multiple_strings` [bad-argument-type]
+ ERROR sockeye/checkpoint_decoder.py:166:83-89: Argument `tuple[Any, ...] | Unknown` is not assignable to parameter `strings` with type `list[str]` in function `sockeye.inference.make_input_from_multiple_strings` [bad-argument-type]
pandas (https://github.com/pandas-dev/pandas)
- ERROR pandas/core/arrays/interval.py:1578:50-58: Argument `NaTType | Period | Timedelta | Timestamp | Any` is not assignable to parameter `right` with type `int` in function `pandas._libs.interval.Interval.__init__` [bad-argument-type]
core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/forked_daapd/media_player.py:782:42-62: Argument `int | list[Unknown]` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR homeassistant/components/forked_daapd/media_player.py:782:42-62: Type `int` is not iterable [not-iterable]
sphinx (https://github.com/sphinx-doc/sphinx)
- ERROR sphinx/domains/cpp/_ast.py:4443:31-45: Argument `list[ASTTemplateIntroduction | ASTTemplateParams] | None` is not assignable to parameter `iterable` with type `Iterable[ASTTemplateIntroduction | ASTTemplateParams]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR sphinx/domains/cpp/_ast.py:4443:31-45: Type `None` is not iterable [not-iterable]
discord.py (https://github.com/Rapptz/discord.py)
- ERROR discord/abc.py:578:44-81: Argument `list[PermissionOverwrite] | list[@_] | object` is not assignable to parameter `iterable` with type `Iterable[@_]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR discord/abc.py:578:44-81: Type `object` is not iterable [not-iterable]
optuna (https://github.com/optuna/optuna)
- ERROR optuna/visualization/_rank.py:273:68-80: Argument `list[float] | None` is not assignable to parameter `iterable` with type `Iterable[float]` in function `enumerate.__new__` [bad-argument-type]
+ ERROR optuna/visualization/_rank.py:273:68-80: Type `None` is not iterable [not-iterable]
schema_salad (https://github.com/common-workflow-language/schema_salad)
+ ERROR src/schema_salad/sourceline.py:224:35-40: Argument `list[int] | list[Never]` is not assignable to parameter `lc` with type `list[int] | None` in function `cmap` [bad-argument-type]
|
Contributor
|
@grievejia has imported this pull request. If you are a Meta employee, you can view this in D111271389. |
yangdanny97
approved these changes
Jul 9, 2026
yangdanny97
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
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
Fixes #1323
Added builtins.enumerate to stdlib type access.
Added a precise builtin enumerate call fast path, using existing iteration logic so tuple literal element types are preserved.
Test Plan
update test