Add PEP 585 (__class_getitem__ -> GenericAlias) support#89
Closed
ToBeReplaced wants to merge 1 commit into
Closed
Conversation
elprans
added a commit
to elprans/pythoncapi-compat
that referenced
this pull request
Sep 13, 2022
Useful for extensions implementing generic container types, like `immutables` (see MagicStack/immutables#89). Co-Authored-By: ToBeReplaced <ToBeReplaced@gmail.com>
elprans
reviewed
Sep 13, 2022
| #endif | ||
|
|
||
|
|
||
| // bpo-39481 added Py_GenericAlias to Python 3.9.0a6. |
Member
There was a problem hiding this comment.
This should probably be added upstream first. I opened python/pythoncapi-compat#45 for that, though if it turns out to be a bad idea we should instead move the ifdef to _map.c
Author
There was a problem hiding this comment.
Yes, you're obviously correct. I was sloppy and didn't realize the compat layer was upstream. Thanks for reviewing and opening the PR to try to do this properly.
Contributor
|
Given the response on python/pythoncapi-compat#45, are you going to finish this PR? Happy to pick it up if you don't have time. |
Member
|
Closing as superseded by #101. Thanks for working on this! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit add supports for PEP 585 on Python 3.9+.
This is useful for runtime introspection ( resolves #83 ).
For example, on Python 3.9+:
On Python 3.8-:
This does not affect type checkers, as they do not utilize runtime introspection.
This is immediately useful for applications that would like to use type information for (de)serialization. Examples:
Thank you for your work on this library (and PEP, to boot!).