-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-39481: Implementation for PEP 585 #18239
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
Merged
Merged
Changes from all commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
d557a64
PEP 585 step 2: Write a Py_GenericAlias() function that returns origin
gvanrossum da33267
PEP 585 step 3: Add Py_GenericAlias() as __class_getitem__ to tuple, …
gvanrossum 447fbe9
PEP 585 step 4: Write some tests
gvanrossum 83e2ba2
Define a GenericAlias (proxy) object (with lots of TODOs still)
gvanrossum fb3e8d3
More tests
gvanrossum 235180b
PEP 585 steps 5-6: Finish basic GenericAlias object and test
gvanrossum 70f3abc
Fix bug with class methods
gvanrossum e4d1356
Define tp_new instead of tp_init
gvanrossum 8f7a55e
Test that list[int][int] fails
gvanrossum f2ba2e5
Test that class L(list): pass; L[int] works
gvanrossum 0af74d1
Implement PEP 585 for collections.deque and ... (#2)
emmatyping b264294
Respond to Serhiy's code review
gvanrossum 0ddea56
📜🤖 Added by blurb_it.
blurb-it[bot] 91edf1c
PEP 585 steps 7-8: Implement repr for GenericAlias (#1)
emmatyping 6b1a218
Add static keyword to ga_repr_item (#3)
emmatyping ce21a96
Add GenericAlias to types.py
gvanrossum dbe67d0
Add test for types.py
gvanrossum 15697f0
Fix tests that were sensitive to the presence of __class_getitem__
gvanrossum da15d43
Fix crash in repr(tuple[...]) -- call PyErr_Clear()
gvanrossum 647cda8
Make re.Match, re.Pattern, and io.IOBase generic (#4)
emmatyping 3824954
Restore parity between _io._IOBase and _pyio.IOBase
gvanrossum 8aec6ae
Make contextlib.Abstract*ContextManager generic, with tests
gvanrossum 58af183
WIP: Tweak test_typing.py to pass with the new definition of __orig_c…
gvanrossum 8da0a08
Rename __parameters__ to __args__
gvanrossum eaecacb
Rename parameters to args
gvanrossum 98d479f
Properly implement __parameters__ as the tuple of args that are type …
gvanrossum 82bc806
Set __orig_class__ if possible when instantiating
gvanrossum 2567ce3
WIP: Implement ga_getitem so list[T][int] -> list[int]
gvanrossum 4f2ced6
Exclude duplicates from __parameters__
gvanrossum 2c25fb0
Implement ga_getitem properly, with tests
gvanrossum 9ed17ef
Implement == and != for GA
gvanrossum bb9a11f
Make collections.abc.* generic (#5)
emmatyping 6d3f535
Make isinstance and issubclass error for GenericAlias (#6)
emmatyping 4b3ecf2
Fix two more AssertIs calls in test_typing.py
gvanrossum 2df602b
Admit defeat -- comment out two expected TypeErrors in test_extended_…
gvanrossum eede65a
Fix whitespace to satisfy patchcheck.py
gvanrossum 2b22f6e
Fix test_site.py
gvanrossum 065a032
Better way to fix test_site.py: don't import types from collections
gvanrossum baf9b32
Use Py_ssize_t instead of int for indexing (#8)
emmatyping 9915ba2
GenericAlias pickle support (#9)
emmatyping 4e1da19
Make type generic (#7)
emmatyping 8926f7a
Remove a completed TODO comment
gvanrossum 7b1ad20
Remove extraneous whitespace. (#10)
emmatyping a05d9ae
Do not make IOBase generic (#11)
emmatyping d4a372b
Remove __class_getitem__ from _pyio.py too; and don't test for IOBase
gvanrossum c534f67
Merge branch 'master' into pep585
gvanrossum 2f94a36
Make types.MappingProxyType generic (#13)
emmatyping 3da2797
Reword isinstance/subclass checks (#12)
emmatyping 13d8d6d
Fix test_types (mappingproxy now has a __class_getitem__ method)
gvanrossum 43a97b9
Merge remote-tracking branch 'upstream/master' into pep585
gvanrossum 4783c2e
Convert some already generic things to GenericAlias to be consistent …
emmatyping e50136d
Make __parameters__ lazy (#15)
emmatyping 0192986
Fix failing test_doctest -- we now find 821 tests
gvanrossum b80b077
Don't import types in os.py -- it breaks test_site.py
gvanrossum 3bc4e12
Move GenericAlias definition to its own file
gvanrossum f658a64
Add a hash function to GenericAlias
gvanrossum bfd6342
Make Union[list[T], int] work
gvanrossum 7919fa2
Add GenericAlias to Windows build (#16)
emmatyping 854fa99
Merge remote-tracking branch 'upstream/master' into pep585
gvanrossum 728084a
Run CI on PRs for pep585 branch
gvanrossum 29130ab
Merge branch 'master' into pep585
gvanrossum ddbce27
Add docstring for GenericAlias (#17)
emmatyping 4db065d
Remove unneeded _GenericAlias definition from collections/__init__.py
gvanrossum e14625f
Make is_typevar() harder to fool
gvanrossum 76c0805
Rewrite ga_repr_item() to honor exceptions
gvanrossum 128aacb
Use __class_getitem__ = classmethod(GenericAlias)
gvanrossum 94f4095
Update Objects/genericaliasobject.c
gvanrossum 79f4170
Apply suggestions from code review
gvanrossum f6f5b81
Use PyTuple_GET_SIZE
gvanrossum 99cac83
Use PyErr_SetString correctly
gvanrossum 6044934
Fix test failure (setattr may raise TypeError)
gvanrossum 355d267
Propagate errors from is_typevar()
gvanrossum 95b3c2a
Use PyObject_Str(qualname)
gvanrossum 13d3742
Merge remote-tracking branch 'upstream/master' into pep585
gvanrossum d3839ea
Delete mention of pep585 branch in GitHub workflow
gvanrossum 31fd842
Move Py_GenericAlias* to genericaliasobject.h
gvanrossum 6bad315
Merge remote-tracking branch 'upstream/master' into pep585
gvanrossum cdb46c3
Add Py_GenericAlias[Type] to PC/python3.ref
gvanrossum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Implementation of PEP 585: support list[int] etc. | ||
#ifndef Py_GENERICALIASOBJECT_H | ||
#define Py_GENERICALIASOBJECT_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
PyAPI_FUNC(PyObject *) Py_GenericAlias(PyObject *, PyObject *); | ||
PyAPI_DATA(PyTypeObject) Py_GenericAliasType; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_GENERICALIASOBJECT_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.