astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.51k stars 1.08k forks source link

Add UP rule: rewrite TypeVar defaults for Generator / AsyncGenerator #13269

Closed hugovk closed 1 month ago

hugovk commented 2 months ago

There's a new check in pyupgrade to rewrite using PEP 696 TypeVar defaults:

from collections.abc import Generator, AsyncGenerator

-def f() -> Generator[int, None, None]:
+def f() -> Generator[int]:
     yield 1
from collections.abc import Generator, AsyncGenerator

-async def f() -> AsyncGenerator[int, None]:
+async def f() -> AsyncGenerator[int]:
     yield 1

See the https://github.com/asottile/pyupgrade/pull/948/files for some variations.

iamlucasvieira commented 2 months ago

May I work on this one?

iamlucasvieira commented 1 month ago

I think we already have this rule implemented: UP043