gh-119180: Add annotationlib module to support PEP 649#119891
gh-119180: Add annotationlib module to support PEP 649#119891JelleZijlstra merged 136 commits intopython:mainfrom
annotationlib module to support PEP 649#119891Conversation
|
This PR is still ready for review. While we will likely make some change related to metaclasses, that won't materially effect the changes here. I'd like to get this PR landed as a foundation to build the rest of the PEP implementation on, so I'd appreciate any reviews. |
Lib/annotationlib.py
Outdated
There was a problem hiding this comment.
Since this (if set) will override the above heuristics on lines 97-107 anyway, why not move it above line 97 so that if we get a globals from __forward_module__ we don't need to bother with those other lookups?
Lib/test/test_annotationlib.py
Outdated
There was a problem hiding this comment.
| sub: a + b, | |
| sub: a - b, |
Lib/test/test_annotationlib.py
Outdated
There was a problem hiding this comment.
| "sub": "a + b", | |
| "sub": "a - b", |
| self.assertEqual(annotationlib.get_annotations(int), {}) | ||
| self.assertEqual(annotationlib.get_annotations(object), {}) | ||
|
|
||
| def test_custom_metaclass(self): |
There was a problem hiding this comment.
Do you plan to add tests here for the pathological cases with metaclass annotations, or make that change in a separate PR?
There was a problem hiding this comment.
I'll leave metaclasses to a separate PR (#119180).
Lib/test/test_annotationlib.py
Outdated
There was a problem hiding this comment.
Are the arguments and their annotations actually related to the test? If not, I'd remove them for clarity about what behavior the test is actually specifying.
|
Thanks @carljm for the review! I pushed fixes for the issues you identified. |
…n#119891) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…n#119891) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This PR implements the
annotationlibmodule proposed by PEP-749, as well as related Python changes for PEP-649 and PEP-749.