Commit Graph

13 Commits

Author SHA1 Message Date
Jelle Zijlstra d3be6f945a
gh-125614: annotationlib: Fix bug where not all Stringifiers are converted (#125635) 2024-10-23 16:27:55 -07:00
larryhastings 626d706a66
Minor edit for code clarification in annotationlib. (#124805) 2024-09-30 15:25:56 -07:00
Jelle Zijlstra 2c10832887
gh-119180: Rename SOURCE format to STRING (#124620) 2024-09-26 13:49:48 -07:00
Jelle Zijlstra 4e829c0e6f
gh-124412: Add helpers for converting annotations to source format (#124551) 2024-09-26 00:01:09 +00:00
Jelle Zijlstra bc543936ab
gh-119180: Make FORWARDREF format look at __annotations__ first (#124479)
From discussion with Larry Hastings and Carl Meyer, this is the desired
behavior.
2024-09-25 15:32:45 -07:00
Jelle Zijlstra 17a544b257
gh-119180: Avoid going through AST and eval() when possible in annotationlib (#124337)
Often, ForwardRefs represent a single simple name. In that case, we
can avoid going through the overhead of creating AST nodes and code
objects and calling eval(): we can simply look up the name directly
in the relevant namespaces.

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-09-25 21:14:03 +00:00
Jelle Zijlstra 2e0d445364
gh-119180: Fix annotationlib.ForwardRef.evaluate with no globals (#124326)
We were sometimes passing None as the globals argument to eval(), which makes it
inherit the globals from the calling scope. Instead, ensure that globals is always
non-None. The test was passing accidentally because I passed "annotationlib" as a
module object; fix that. Also document the parameters to ForwardRef() and remove
two unused private ones.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-09-23 19:06:19 +00:00
Jelle Zijlstra 96f619faa7
gh-124206: Fix calling get_annotate_function() on static types (#124208)
Fixes #124206. No news entry because the bug this fixes was never
released.
2024-09-18 08:39:22 -07:00
Jelle Zijlstra 4534068f22
gh-119180: annotationlib: Fix __all__, formatting (#122365) 2024-08-11 23:44:51 +00:00
Jelle Zijlstra 016f4b5975
gh-119180: Improvements to ForwardRef.evaluate (#122210)
Noticed some issues while writing documentation for this method.
2024-08-11 23:42:57 +00:00
Jelle Zijlstra ae192262ad
gh-119180: Add evaluate functions for type params and type aliases (#122212) 2024-07-27 17:24:10 +00:00
Jelle Zijlstra 45614ecb2b
gh-119180: Use type descriptors to access annotations (PEP 749) (#122074) 2024-07-27 16:36:06 +00:00
Jelle Zijlstra 7b7b90d1ce
gh-119180: Add `annotationlib` module to support PEP 649 (#119891)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-07-23 21:16:50 +00:00