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

Rules pertaining to PEP 695 #12542

Closed
Goldziher opened this issue Jul 27, 2024 · 4 comments · Fixed by #15565
Closed

Rules pertaining to PEP 695 #12542

Goldziher opened this issue Jul 27, 2024 · 4 comments · Fixed by #15565
Labels
rule Implementing or modifying a lint rule

Comments

@Goldziher
Copy link

MyPy released support for PEP 695 generics: python/mypy#15238

It would be awesome to do any of the following:

  1. get linting errors for code that uses older style generics (TypeVar, ParamSpec etc.) for Python 3.12+
  2. get linting errors for code that uses newer style generics and should be backward compatible with lower Python versions
  3. automagically upgrade older style generics to use the new syntax

I see that for point 3 there is an open related issue. This issue is about the underlying rust implementation for point 3, but does not cover points 1 and 2.

@charliermarsh
Copy link
Member

We have some support for this already in https://docs.astral.sh/ruff/rules/non-pep695-type-alias/. I believe that rule does (1) and (3)?

@Goldziher
Copy link
Author

We have some support for this already in https://docs.astral.sh/ruff/rules/non-pep695-type-alias/. I believe that rule does (1) and (3)?

I don't think so. I might be wrong but it seems to me like this rule is concerned with the TypeAlias type.

I am talking about the new generics style: https://peps.python.org/pep-0695/#summary-examples

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Jul 27, 2024
@charliermarsh
Copy link
Member

Thanks, you're right, that's my mistake. We may want to fold this into #4617, and just flesh out that issue a bit more.

@ntBre
Copy link
Contributor

ntBre commented Jan 22, 2025

Cases (1) and (3) should now be handled by the rules UP046 and UP047 added in #15565, with a few caveats being tracked in #15642.

I think case (2) would be a good fit for the "pydowngrade" suggestion from #2501, so I'm closing this and making a comment there.

@ntBre ntBre mentioned this issue Jan 22, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants