diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2024-07-23 21:16:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-23 21:16:50 (GMT) |
commit | 7b7b90d1ce5116f29ad6c8120c0490824baa54e0 (patch) | |
tree | b273afb5767b7a55fb52a277cc9512ebfc4ac12d /Lib/dataclasses.py | |
parent | 64e221d7ada8f6c20189035c7e81503f4c914f04 (diff) | |
download | cpython-7b7b90d1ce5116f29ad6c8120c0490824baa54e0.zip cpython-7b7b90d1ce5116f29ad6c8120c0490824baa54e0.tar.gz cpython-7b7b90d1ce5116f29ad6c8120c0490824baa54e0.tar.bz2 |
gh-119180: Add `annotationlib` module to support PEP 649 (#119891)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r-- | Lib/dataclasses.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 74011b7..4cba606 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -5,6 +5,7 @@ import types import inspect import keyword import itertools +import annotationlib import abc from reprlib import recursive_repr @@ -981,7 +982,8 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, # actual default value. Pseudo-fields ClassVars and InitVars are # included, despite the fact that they're not real fields. That's # dealt with later. - cls_annotations = inspect.get_annotations(cls) + cls_annotations = annotationlib.get_annotations( + cls, format=annotationlib.Format.FORWARDREF) # Now find fields in our class. While doing so, validate some # things, and set the default values (as class attributes) where |