Skip to content

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

@cake-monotone

Description

@cake-monotone

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions