Skip to content

PEP 695 (Type Parameter Syntax) tracker - Generics #10869

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

Open
5 tasks
srittau opened this issue Oct 11, 2023 · 3 comments
Open
5 tasks

PEP 695 (Type Parameter Syntax) tracker - Generics #10869

srittau opened this issue Oct 11, 2023 · 3 comments
Labels
project: feature tracker Tracks whether a typing feature can be used in typeshed stubs

Comments

@srittau
Copy link
Collaborator

srittau commented Oct 11, 2023

This issue is supposed to track when we can start to use the improved generics syntax introduced in Python 3.12 (PEP 695 in typeshed. Support is needed in released versions of:

  • mypy
  • pytype
  • pyright
  • pyre
  • PyCharm (optional)

As this is a syntax change, it's unlikely that we can add support before mypy drops support for running under Python 3.11 and below.

Example from the PEP:

class ClassA[T: str]:
    def method1(self) -> T:
        ...

def func[T](a: T, b: T) -> T:
    ...
@srittau srittau added the project: feature tracker Tracks whether a typing feature can be used in typeshed stubs label Oct 11, 2023
@Akuli
Copy link
Collaborator

Akuli commented Oct 12, 2023

I think we can never fully switch to the new syntax, because sometimes we need to choose a variance that type checkers disagree with, as in #8781.

@AlexWaygood
Copy link
Member

I think we can never fully switch to the new syntax, because sometimes we need to choose a variance that type checkers disagree with, as in #8781.

That will be quite rare, though; we can aspire to use the new syntax nearly all of the time

@srittau
Copy link
Collaborator Author

srittau commented Oct 12, 2023

We also occasionally have public type vars, but I agree with Alex that we should at least aspire to use the new syntax. (In five years or so.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: feature tracker Tracks whether a typing feature can be used in typeshed stubs
Projects
None yet
Development

No branches or pull requests

3 participants