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

UP043 only applies to typing.Generator, not collections.abc.Generator #13602

Closed
cake-monotone opened this issue Oct 2, 2024 · 2 comments · Fixed by #13611
Closed

UP043 only applies to typing.Generator, not collections.abc.Generator #13602

cake-monotone opened this issue Oct 2, 2024 · 2 comments · Fixed by #13611
Assignees
Labels
bug Something isn't working

Comments

@cake-monotone
Copy link
Contributor

UP043

UP043
Python 3.13 introduced the ability for type parameters to specify default values. As such, the default type arguments for some types in the standard library (e.g., Generator, AsyncGenerator) are now optional.
Omitting type parameters that match the default values can make the code more concise and easier to read.

Generator[int, None, None] -> Generator[int]

issue

Currently, UP043 only applies to typing.Generator, but it should also support collections.abc.Generator.

Example

from collections.abc import Generator
from typing import Generator as tG

a = Generator[int, None, None] # No warns
b = tG[int, None, None]  # UP043

https://play.ruff.rs/e09a4a44-7af6-4b17-ab37-ce0ba2d1ccf6

@cake-monotone
Copy link
Contributor Author

May I work on this one?

@AlexWaygood
Copy link
Member

May I work on this one?

Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants