-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-41428: Implementation for PEP 604 #21515
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
62 commits
Select commit
Hold shift + click to select a range
4c4c701
Add new type object for union types
MaggieMoss 07b5c29
Add test.
MaggieMoss 32c207b
Add basic tp_* fields to union object
MaggieMoss 50b33c2
Squash this commit.
MaggieMoss 8901145
Squash this commit.
MaggieMoss 6450321
Add union_traverse method.
MaggieMoss 8a09a92
Handle Py_None in union.
MaggieMoss e3c80e9
Clean up syntax with Py_None
MaggieMoss 165c323
Update getattro method.
MaggieMoss 7f0018e
Reduce code duplication when adding union types together.
MaggieMoss cd584d5
Add __or__ method to _SpecialGenericAlias
MaggieMoss ba031c1
Add support for NewType with unions.
MaggieMoss e62de73
Remove old code from abstract.c
MaggieMoss f6ab05b
Fix warning for incompatible pointer type.
MaggieMoss 9c20fbc
Add support for union use in subclasses.
MaggieMoss 9f48989
Fix code style inconsistencies.
MaggieMoss a0cd651
Change is_not_union -> is_union
MaggieMoss a5c6850
Implement dedup and flatten.
MaggieMoss 5255f4f
Add basic tp_repr to unionobject.
MaggieMoss 1732fad
Update is_unionable.
MaggieMoss 31653dc
Clean up whitespace.
MaggieMoss 2ffb050
Update test_types.
MaggieMoss 3fed944
Fix style and grammar issues.
MaggieMoss a1c703b
Implement NE for union richcompare.
MaggieMoss c4acc73
Remove is_generic_alias helper method.
MaggieMoss 6a8dfe9
Fix negative ref count.
MaggieMoss af59751
Small code style fixes.
MaggieMoss cae1a38
Add unionobject to pythoncore.vcxproj.filters
MaggieMoss 0cb47c1
Remove semicolon after PyObject_HEAD
MaggieMoss 265be78
Use _PyTuple_Resize instead of variable length array.
MaggieMoss 6fddcd6
Add error handling.
MaggieMoss 60f023a
Add additional tests for union_richcompare.
MaggieMoss 99ba1fd
📜🤖 Added by blurb_it.
blurb-it[bot] ad945fd
Update error check for PySet_New call.
MaggieMoss 0586c41
Allow Any and other _SpecialForm
MaggieMoss e44a657
Update repr to handle NoneType properly.
MaggieMoss ba3110c
Add Union to types.py
MaggieMoss 7bec987
Merge branch 'PEP605-implementation' of github.com:MaggieMoss/cpython…
MaggieMoss e052c53
Remove commented out code.
MaggieMoss 15e0d29
Update test with nested unions.
MaggieMoss 2e31288
Add additional tests for optionals.
MaggieMoss 2a12a43
Add support for int | int == int
MaggieMoss 7116cd9
Add more error handling to unionobject
MaggieMoss 2c0befb
Handle NoneType vs. None
MaggieMoss 8d59e44
Don't allow generics in isinstance calls.
MaggieMoss 9f014e2
Add errors for union subclass.
MaggieMoss 30bb872
Implement code review suggestions.
MaggieMoss 6fe4956
Increase code sharing between is_typing_name and is_new_type
MaggieMoss bae3d2a
Add tests, fix reference leaks.
MaggieMoss 17a7277
Update tp_flags for unionobject.
MaggieMoss f47bce0
Return int.
MaggieMoss 0735352
Fix NoneType comparison side effect.
MaggieMoss b2910f0
Merge branch 'PEP605-implementation' of github.com:MaggieMoss/cpython…
MaggieMoss e9e5a5e
Remove GC flag from unionobject.
MaggieMoss 385a338
Implement code review suggestions
MaggieMoss dddc598
Refactor and remove PyUnion_New
MaggieMoss 8c06c1d
General cleanup, fix reference leaks, add new test for possible crashes
pablogsal 37699f1
Add newline
pablogsal 47a4cb3
Make unionobject APIs private
pablogsal 7f89abd
Add minor test for GenericAlias
pablogsal d0be56f
Remove ellipsis from repr.
MaggieMoss 59f06f7
Remove commented out test code.
MaggieMoss 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef Py_INTERNAL_UNIONOBJECT_H | ||
#define Py_INTERNAL_UNIONOBJECT_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef Py_BUILD_CORE | ||
# error "this header requires Py_BUILD_CORE define" | ||
#endif | ||
|
||
PyAPI_FUNC(PyObject *) _Py_Union(PyObject *args); | ||
PyAPI_DATA(PyTypeObject) _Py_UnionType; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_INTERNAL_UNIONOBJECT_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
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Core and Builtins/2020-07-28-22-43-27.bpo-41428.FM6xsI.rst
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 @@ | ||
Implement PEP 604. This supports (int | str) etc. in place of Union[str, int]. |
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.