GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-103763: Implement PEP 695 by JelleZijlstra · Pull Request #103764 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Apr 24, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I will update this message as the status of the PR changes.

This is a complete implementation. It incorporates the changes in python/peps#3122, which were approved by the SC.

I wrote a detailed account of the changes in this PR at https://jellezijlstra.github.io/pep695

Reviews are welcome on any aspect of the implementation.

  • Issue: Implement PEP 695 #103763

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Soberia, SigureMo, shiningmatcha, efimov-mikhail, and FrancescoPezzella reacted with thumbs up emoji antonagestam, SigureMo, shiningmatcha, CoolCat467, and FrancescoPezzella reacted with heart emoji
All reactions
  • 👍 5 reactions
  • ❤️ 5 reactions
msfterictraut and others added 30 commits April 8, 2023 18:04
@msfterictraut
Moved portions of earlier prototype into latest main CPython branch. …
9c8cd71
…This commit includes:

1. Parser updates
2. AST updates
3. typing.py updates
4. Unit tests

It does not include the following:
5. Symtable updates
6. Compiler updates
7. C implementations of TypeVar, TypeVarTuple, ParamSpec, Generic
@JelleZijlstra
Run Tools/build/generate_global_objects.py
609ac0d
This fixes compilation for me locally.
@JelleZijlstra
Basic C implementation of TypeVar, TypeVarTuple, ParamSpec
7a5e457
This isn't fully functional, but it should be enough to unblock work
on the runtime. I'll update this PR as I implement more.
@JelleZijlstra
fix TypeVar signature
1e0b74c
@JelleZijlstra
fix TypeVar argument parsing
2a5023a
@JelleZijlstra
ParamSpecArgs/Kwargs
1bc8574
@JelleZijlstra
make typing importable
ed42796
@JelleZijlstra
Add some things
d06f43d
@msfterictraut
Updated unit tests to reflect the latest PEP 695 spec.
830b36a
@JelleZijlstra
Merge remote-tracking branch 'erictraut/type_param_syntax4' into tvob…
b6bf2bc
…ject
@JelleZijlstra
Make *Ts work
6bb4795
@JelleZijlstra
Just call typing.py
c7c1618
@JelleZijlstra
attempt at pickling
772920f
@JelleZijlstra
better approach
6ff6f5a
@JelleZijlstra
fix a few tests and refcount bugs
9fdf373
@cdce8p
Use Name expr for TypeAlias
f7c513d
@cdce8p
Add ast optimizer for typeparam
1d7b035
@cdce8p
Use Name expr for TypeParameter
85a4409
@cdce8p
Revert AST changes for TypeParams
55d0fd9
@erictraut
Merge pull request python#7 from cdce8p/eric-ast-changes
618e173
AST changes
@JelleZijlstra
broken compiler before merge
bef978f
@JelleZijlstra
Merge remote-tracking branch 'erictraut/type_param_syntax4' into tvob…
3cd026a
…ject
@JelleZijlstra
Works for functions
b12663d
@JelleZijlstra
fall back to normal scope
bb9c43c
@JelleZijlstra
does not exactly work
037ddfa
@JelleZijlstra
commit before new approach
a62f0c2
@JelleZijlstra
New approach
9c7a153
@JelleZijlstra
correctly make it a cellvar
aa8ea68
@JelleZijlstra
Now it works
ab6b718
@JelleZijlstra
fix defaults
dba4293
@JelleZijlstra
JelleZijlstra merged commit 24d8b88 into python:main May 16, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label May 16, 2023
@gvanrossum

gvanrossum commented May 16, 2023

Copy link
Copy Markdown
Member

🎉

antonagestam, erictraut, Fidget-Spinner, sobolevn, carljm, Bluesy1, Mega-JC, and danohn reacted with hooray emoji
All reactions
  • 🎉 8 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

carljm added a commit to carljm/cpython that referenced this pull request May 16, 2023
@carljm
Merge branch 'main' into supermon
a6dd626
* 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)
@carljm

carljm commented May 16, 2023

Copy link
Copy Markdown
Member

Congrats! Really excellent work on a tight timeframe.

AlexWaygood, antonagestam, Fidget-Spinner, Mega-JC, and j178 reacted with thumbs up emoji
All reactions
  • 👍 5 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nedbat nedbat mentioned this pull request May 20, 2023
PEP 695 changed how class decorators are traced #104686
Closed
@zen-xu

zen-xu commented May 23, 2023

Copy link
Copy Markdown

Awesome!

But will python support Multiple bounds like rust

from typing import Protocol

class Dance(Protocol):
    def dance(self): ...

class Sing(Protocol):
    def sing(self): ...

def perform[P: Dance + Sing](person: P):
    person.dance()
    person.sing()
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sunmy2019

sunmy2019 commented May 23, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

But will python support Multiple bounds like rust

from typing import Protocol

class Dance(Protocol):
    def dance(self): ...

class Sing(Protocol):
    def sing(self): ...

def perform[P: Dance + Sing](person: P):
    person.dance()
    person.sing()

It will not, at least not soon. Changes like this often need a PEP. If you are interested in it, new ideas are welcomed at https://discuss.python.org/c/ideas/6.

As for this specific question, I think you are asking for a typing.Intersection[Dance, Sing]. Some relevant issues here: python/typing#18

https://discuss.python.org/t/type-intersection-and-negation-in-type-annotations/23879

AlexWaygood, zen-xu, and JelleZijlstra reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@junkmd

junkmd commented May 27, 2023

Copy link
Copy Markdown
Contributor

Adding the feature like a Multiple bounds by using a Intersection symbol and/or an & operator has been discussed for over 6 years at python/typing#213.

I hope that the adoption of PEP695 will lead to more discussion on this as well and improve the representation of type hints.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn sobolevn mentioned this pull request Jun 7, 2023
PEP 695: not all name collisions are tested #105437
Closed
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 22, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
9d54dd9
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 22, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
8113c95
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 22, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
415468a
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 22, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
d3bad65
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 22, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
580eb7e
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 22, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
4fb6861
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 23, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
bd9e62d
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this pull request Jun 25, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
e6208bc
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
jacobtylerwalls added a commit to pylint-dev/astroid that referenced this pull request Jun 27, 2023
@jacobtylerwalls
Python 3.12 adjustments for typing brain
f2120db
A C-accelerator was introduced for the typing module in
Python 3.12 (see python/cpython#103764).

Because a pure python source is no longer available, now we stub
out the missing classes and provide some __class_getitem__
methods to allow subscripting like Type[int].

This may mean when 3.12 is the minimum, we can remove older
brain features like infer_typing_alias().
@gvanrossum gvanrossum mentioned this pull request Jul 14, 2023
gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c #106758
Merged
@AlexWaygood

AlexWaygood commented Aug 20, 2023

Copy link
Copy Markdown
Member

@python/organization-owners, please block @johnnyjeannatasha as a spammer — see the review on this PR and the comment at a390ec2#commitcomment-124994466

ewdurbin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gouzil gouzil mentioned this pull request Feb 22, 2024
[SOT][3.12] Support CALL_INTRINSIC_1 opcode in Python 3.12 PaddlePaddle/Paddle#61995
Merged
@JelleZijlstra
JelleZijlstra deleted the tvobject branch September 9, 2024 21:15
@JelleZijlstra JelleZijlstra mentioned this pull request Sep 9, 2024
gh-123881: make compiler add the .generic_base base class without constructing AST nodes #123883
Merged
@JelleZijlstra
JelleZijlstra restored the tvobject branch September 10, 2024 23:37
@AA-Turner AA-Turner mentioned this pull request Oct 19, 2024
Use the latest Sphinx version #125722
Closed
@brianschubert brianschubert mentioned this pull request Sep 15, 2025
Fix error message when subclassing TypeVarTuple python/typing_extensions#679
Open
@BarrensZeppelin BarrensZeppelin mentioned this pull request Feb 3, 2026
Implement preliminary PEP 695 support pypy/pypy#5371
Merged
@jeremyhylton jeremyhylton mentioned this pull request Jul 14, 2026
erroneous behavior when creating classes inside a closure #53472
Open
@coderabbitai coderabbitai Bot mentioned this pull request Aug 18, 2026
builtins, code objects, gc, and typing: CPython 3.14 surface completions pyre-lang/pyre#1332
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@carljm carljm carljm approved these changes
@iritkatriel iritkatriel iritkatriel left review comments
@arhadthedev arhadthedev arhadthedev left review comments
@markshannon markshannon markshannon left review comments
@lysnikolaou lysnikolaou lysnikolaou left review comments
@Fidget-Spinner Fidget-Spinner Fidget-Spinner left review comments
@sunmy2019 sunmy2019 sunmy2019 left review comments
@AlexWaygood AlexWaygood AlexWaygood left review comments
@Eclips4 Eclips4 Eclips4 left review comments
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@isidentical isidentical Awaiting requested review from isidentical isidentical is a code owner
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@encukou encukou Awaiting requested review from encukou
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner
+1 more reviewer
@TeamSpen210 TeamSpen210 TeamSpen210 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-typing type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

19 participants

@JelleZijlstra @TeamSpen210 @sunmy2019 @Eclips4 @bedevere-bot @gvanrossum @Fidget-Spinner @markshannon @carljm @zen-xu @junkmd @AlexWaygood @iritkatriel @arhadthedev @lysnikolaou @msfterictraut @cdce8p @erictraut @larryhastings
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.