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

Implement PEP 695 #103763

Closed
4 tasks
JelleZijlstra opened this issue Apr 24, 2023 · 6 comments
Closed
4 tasks

Implement PEP 695 #103763

JelleZijlstra opened this issue Apr 24, 2023 · 6 comments
Assignees
Labels
topic-typing type-feature A feature request or enhancement

Comments

@JelleZijlstra
Copy link
Member

JelleZijlstra commented Apr 24, 2023

We should implement PEP-695. Some discussion of the implementation is at https://github.com/erictraut/cpython/issues. I will open a draft PR momentarily.

TODO:

  • Evaluate TypeAlias values
  • Lazy evaluation for TypeVar bounds
  • More tests
  • Fix remaining tests in test_typing.py

Linked PRs

@JelleZijlstra JelleZijlstra added the type-feature A feature request or enhancement label Apr 24, 2023
@JelleZijlstra JelleZijlstra self-assigned this Apr 24, 2023
@preveen-stack
Copy link

PEP 695 – Type Parameter Syntax

@sunmy2019
Copy link
Member

Wow. This syntax looks so cool. It reminds me of many generic expressions in other languages, such as C++ and Rust. (while the increases the learning curve of Python)

I'll see what I can help here.

@preveen-stack
Copy link

I feel we should defend the intuitive readability of python irrespective of what.

JelleZijlstra added a commit that referenced this issue May 16, 2023
This implements PEP 695, Type Parameter Syntax. It adds support for:

- Generic functions (def func[T](): ...)
- Generic classes (class X[T](): ...)
- Type aliases (type X = ...)
- New scoping when the new syntax is used within a class body
- Compiler and interpreter changes to support the new syntax and scoping rules 

Co-authored-by: Marc Mueller <[email protected]>
Co-authored-by: Eric Traut <[email protected]>
Co-authored-by: Larry Hastings <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
@JelleZijlstra
Copy link
Member Author

The implementation is done. The next step is #103921, the documentation.

carljm added a commit to carljm/cpython that referenced this issue May 16, 2023
* main:
  pythonGH-104510: Fix refleaks in `_io` base types (python#104516)
  pythongh-104539: Fix indentation error in logging.config.rst (python#104545)
  pythongh-104050: Don't star-import 'types' in Argument Clinic (python#104543)
  pythongh-104050: Add basic typing to CConverter in clinic.py (python#104538)
  pythongh-64595: Fix write file logic in Argument Clinic (python#104507)
  pythongh-104523: Inline minimal PGO rules (python#104524)
  pythongh-103861: Fix Zip64 extensions not being properly applied in some cases (python#103863)
  pythongh-69152: add method get_proxy_response_headers to HTTPConnection class (python#104248)
  pythongh-103763: Implement PEP 695 (python#103764)
  pythongh-104461: Run tkinter test_configure_screen on X11 only (pythonGH-104462)
  pythongh-104469: Convert _testcapi/watchers.c to use Argument Clinic (python#104503)
  pythongh-104482: Fix error handling bugs in ast.c (python#104483)
  pythongh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization (pythongh-104437)
  pythonGH-102613: Fix recursion error from `pathlib.Path.glob()` (pythonGH-104373)
@charliermarsh
Copy link

@JelleZijlstra - I'm sorry if this is the wrong place to ask, but is the specification and implementation of PEP 695 sufficiently stabilized that I could look into updating Ruff's parser and semantic model to support them?

@JelleZijlstra
Copy link
Member Author

I don't expect more major changes, no. There are currently no open PEP 695-related bugs; if anything else changes it would be as a result of new feedback we receive during the beta phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-typing type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

5 participants