| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
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 a problem hiding this comment.
This looks good to me!
Sorry, something went wrong.
| 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.
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.
| def test_expressions(self): | ||
| def f( | ||
| add: a + b, | ||
| sub: a + b, |
There was a problem hiding this comment.
| sub: a + b, | |
| sub: a - b, |
Sorry, something went wrong.
| anno, | ||
| { | ||
| "add": "a + b", | ||
| "sub": "a + b", |
There was a problem hiding this comment.
| "sub": "a + b", | |
| "sub": "a - b", |
Sorry, something went wrong.
| 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?
Sorry, something went wrong.
There was a problem hiding this comment.
I'll leave metaclasses to a separate PR (#119180).
Sorry, something went wrong.
|
|
||
| def test_custom_object_with_annotations(self): | ||
| class C: | ||
| def __init__(self, x: int = 0, y: str = ""): |
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.
Sorry, something went wrong.
|
Thanks @carljm for the review! I pushed fixes for the issues you identified. |
Sorry, something went wrong.
…n#119891) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…n#119891) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
| Back | FazBrowse Home | New Git URL |
This PR implements the annotationlib module proposed by PEP-749, as well as related Python changes for PEP-649 and PEP-749.