Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iteration over union (when self type is involved) #17976

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

hauntsaninja
Copy link
Collaborator

Fixes #17945

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/elements/lib/column_config_utils_test.py:385:30: error: Invalid index type "str" for "Union[ColumnConfig, str, None]"; expected type "Union[SupportsIndex, slice]"  [index]
+ lib/tests/streamlit/elements/lib/column_config_utils_test.py:385:30: error: Invalid index type "str" for "str"; expected type "Union[SupportsIndex, slice]"  [index]

spack (https://github.com/spack/spack)
- lib/spack/spack/util/spack_yaml.py:490: error: Item "dict_items[Any, Any]" of "Iterator[tuple[Any, Any]] | dict_items[Any, Any] | enumerate[Any]" has no attribute "__next__"  [union-attr]

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@JukkaL JukkaL merged commit 539513a into python:master Oct 17, 2024
17 checks passed
@hauntsaninja hauntsaninja deleted the mypy-union-2 branch October 17, 2024 09:30
hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull request Oct 18, 2024
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.12 regression] False positive when iterating over union
2 participants