Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Revert "Remove redundant inheritances from Iterator in itertools (#12816)" #12853

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

Closed
wants to merge 1 commit into from

Conversation

tungol
Copy link
Contributor

@tungol tungol commented Oct 18, 2024

This reverts commit 281dd35.

This one wasn't quite baked yet.

#12816

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you!

@AlexWaygood AlexWaygood requested a review from srittau October 18, 2024 18:05
@tungol
Copy link
Contributor Author

tungol commented Oct 18, 2024

No problem; I wouldn't want changes to go through that haven't gotten the vetting that they need.

Copy link
Contributor

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

python-chess (https://github.com/niklasf/python-chess)
- chess/pgn.py:194: error: No overload variant of "iter" matches argument type "object"  [call-overload]
- chess/pgn.py:194: note: Possible overload variants:
- chess/pgn.py:194: note:     def [_SupportsNextT: SupportsNext[Any]] iter(SupportsIter[_SupportsNextT], /) -> _SupportsNextT
- chess/pgn.py:194: note:     def [_T] iter(_GetItemIterable[_T], /) -> Iterator[_T]
- chess/pgn.py:194: note:     def [_T] iter(Callable[[], _T | None], None, /) -> Iterator[_T]
- chess/pgn.py:194: note:     def [_T] iter(Callable[[], _T], object, /) -> Iterator[_T]

jax (https://github.com/google/jax)
- jax/_src/numpy/linalg.py:2087: error: Unused "type: ignore" comment  [unused-ignore]

xarray (https://github.com/pydata/xarray)
- xarray/core/dataset.py: note: In function "_get_chunk":
- xarray/core/dataset.py:280: error: Argument 1 to "difference" of "set" has incompatible type "object"; expected "Iterable[Any]"  [arg-type]
- xarray/core/dataset.py: note: At top level:

@hauntsaninja
Copy link
Collaborator

Given that mypy 1.12 uses unions for ternary, we could try this again after we update typeshed to mypy 1.12: https://github.com/python/typeshed/blob/main/requirements-tests.txt#L3

@srittau
Copy link
Collaborator

srittau commented Oct 18, 2024

Given that mypy 1.12 uses unions for ternary, we could try this again after we update typeshed to mypy 1.12: https://github.com/python/typeshed/blob/main/requirements-tests.txt#L3

So, update first and see whether this helps? This doesn't seem time critical, as I don't think mypy 1.13 is going to be released in the next few days.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Oct 18, 2024

Funnily enough I think there will be a mypy 1.13 in the next few days, but it won't include a typeshed sync so we're fine :-)

So no time pressure, but would be good to confirm against mypy_primer. Merging this revert might still be the easiest way to do that. Or I guess seeing what it looks like on next typeshed sync to mypy

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Oct 18, 2024

I kicked off a sync in python/mypy#17994

@tungol
Copy link
Contributor Author

tungol commented Oct 18, 2024

Looks like 1.12 does fix the issue with ternary expressions. The change for jax is still there.

I think that jax is surfacing the same underlying issue as ibis and psycopg in #12851 (comment) ; They all have the form func(*iterator), and have what I believe to be a correct warning going away when the class doesn't explicitly inherit from Iterator.

I don't have an opinion myself as to whether this should or shouldn't block the change.

@hauntsaninja
Copy link
Collaborator

I think this means we're all good and this revert can be closed :-)

@tungol
Copy link
Contributor Author

tungol commented Oct 19, 2024

Closing this out then.

@tungol tungol closed this Oct 19, 2024
@tungol tungol deleted the itertools branch October 23, 2024 17:06
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.

5 participants