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 tqdm.asyncio type inconsistency #13259

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Fix tqdm.asyncio type inconsistency #13259

merged 2 commits into from
Dec 19, 2024

Conversation

kbaikov
Copy link
Contributor

@kbaikov kbaikov commented Dec 17, 2024

Fixes #13227

This comment has been minimized.

@@ -84,7 +84,7 @@ class tqdm_asyncio(std_tqdm[_T]):
@overload
def __init__(
self,
iterable: Iterable[_T],
iterable: Iterable[_T] | Iterator[_T] | AsyncIterator[_T],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Iterable is redundant, as each Iterator is an Iterable.

Suggested change
iterable: Iterable[_T] | Iterator[_T] | AsyncIterator[_T],
iterable: Iterator[_T] | AsyncIterator[_T],

Choose a reason for hiding this comment

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

Iterable[_T] is still a valid type, so Iterator[_T] should probably be removed instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks to me that @mattmess1221 is correct, just because this code fallsback to iter(iterable), so they will create an Iterator themselves from Iterable.
The code in question: https://github.com/tqdm/tqdm/blob/0ed5d7f18fa3153834cbac0aa57e8092b217cc16/tqdm/asyncio.py#L26-L34

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are correct, of course. Iterator is redundant.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit d31e3ea into python:main Dec 19, 2024
48 checks passed
@kbaikov kbaikov deleted the fix-tqdm branch December 19, 2024 10:20
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.

tqdm.asyncio type inconsistency
3 participants