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

Add rule for using PEP696 default type params #12286

Closed
janosh opened this issue Jul 11, 2024 · 4 comments
Closed

Add rule for using PEP696 default type params #12286

janosh opened this issue Jul 11, 2024 · 4 comments
Labels
accepted Ready for implementation good first issue Good for newcomers python313 Related to Python 3.13 rule Implementing or modifying a lint rule

Comments

@janosh
Copy link

janosh commented Jul 11, 2024

PEP 696 allows cleaning up code like

from typing import Generator

def gen() -> Generator[int, None, None]:  # bad (on 3.13+)
    yield 42

def gen() -> Generator[int]:  # good
    yield 42

would be great if ruff had an auto-fix for that if the target version is at least 3.13

@dhruvmanila
Copy link
Member

Seems like a good idea. Thanks for raising this request. Do you know if there are any other types like Generator that has been changed? I think AsyncGenerator can also be considered.

@dhruvmanila dhruvmanila added rule Implementing or modifying a lint rule python313 Related to Python 3.13 labels Jul 11, 2024
@charliermarsh charliermarsh added good first issue Good for newcomers accepted Ready for implementation labels Jul 12, 2024
@charliermarsh
Copy link
Member

PR welcome, we can put it under the UP category.

charliermarsh pushed a commit that referenced this issue Jul 17, 2024
…2371)

## Summary

Add new rule and implement for `unnecessary default type arguments`
under the `UP` category (`UP043`).

```py
// < py313
Generator[int, None, None] 

// >= py313
Generator[int]
```

I think that as Python 3.13 develops, there might be more default type
arguments added besides `Generator` and `AsyncGenerator`. So, I made
this more flexible to accommodate future changes.

related issue: #12286

## Test Plan

snapshot included..!
@janosh
Copy link
Author

janosh commented Jul 18, 2024

looks like this can be closed since #12371 was implemented and merged in record time as usual. thanks! 👍

@janosh janosh closed this as completed Jul 18, 2024
@charliermarsh
Copy link
Member

Good call, thanks @janosh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation good first issue Good for newcomers python313 Related to Python 3.13 rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

3 participants