Skip to content

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

Closed
tungol wants to merge 1 commit into
python:mainfrom
tungol:itertools
Closed

Revert "Remove redundant inheritances from Iterator in itertools (#12816)"#12853
tungol wants to merge 1 commit into
python:mainfrom
tungol:itertools

Conversation

@tungol

@tungol tungol commented Oct 18, 2024

Copy link
Copy Markdown
Contributor

This reverts commit 281dd35.

This one wasn't quite baked yet.

#12816

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

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

tungol commented Oct 18, 2024

Copy link
Copy Markdown
Contributor Author

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

@github-actions

Copy link
Copy Markdown
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
Copy Markdown
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

srittau commented Oct 18, 2024

Copy link
Copy Markdown
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

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

hauntsaninja commented Oct 18, 2024

Copy link
Copy Markdown
Collaborator

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

hauntsaninja commented Oct 18, 2024

Copy link
Copy Markdown
Collaborator

I kicked off a sync in python/mypy#17994

@tungol

tungol commented Oct 18, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Collaborator

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

@tungol

tungol commented Oct 19, 2024

Copy link
Copy Markdown
Contributor Author

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