GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-119180: Add `annotationlib` module to support PEP 649 by JelleZijlstra · Pull Request #119891 · python/cpython Conversation
|
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if self.__forward_module__ is not None: | ||
| globals = getattr( | ||
| sys.modules.get(self.__forward_module__, None), "__dict__", globals | ||
| ) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| def test_expressions(self): | ||
| def f( | ||
| add: a + b, | ||
| sub: a + b, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| sub: a + b, | |
| sub: a - b, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| anno, | ||
| { | ||
| "add": "a + b", | ||
| "sub": "a + b", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| "sub": "a + b", | |
| "sub": "a - b", |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertEqual(annotationlib.get_annotations(int), {}) | ||
| self.assertEqual(annotationlib.get_annotations(object), {}) | ||
|
|
||
| def test_custom_metaclass(self): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Do you plan to add tests here for the pathological cases with metaclass annotations, or make that change in a separate PR?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll leave metaclasses to a separate PR (#119180).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_custom_object_with_annotations(self): | ||
| class C: | ||
| def __init__(self, x: int = 0, y: str = ""): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @carljm for the review! I pushed fixes for the issues you identified. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…n#119891) Co-authored-by: Alex Waygood <[email protected]>
…n#119891) Co-authored-by: Alex Waygood <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.