mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-119180: Add VALUE_WITH_FAKE_GLOBALS format to annotationlib (#124415)
This commit is contained in:
parent
2b0e2b2893
commit
dcf629213b
8 changed files with 73 additions and 26 deletions
|
|
@ -2936,10 +2936,13 @@ def _make_eager_annotate(types):
|
|||
checked_types = {key: _type_check(val, f"field {key} annotation must be a type")
|
||||
for key, val in types.items()}
|
||||
def annotate(format):
|
||||
if format in (annotationlib.Format.VALUE, annotationlib.Format.FORWARDREF):
|
||||
return checked_types
|
||||
else:
|
||||
return annotationlib.annotations_to_string(types)
|
||||
match format:
|
||||
case annotationlib.Format.VALUE | annotationlib.Format.FORWARDREF:
|
||||
return checked_types
|
||||
case annotationlib.Format.STRING:
|
||||
return annotationlib.annotations_to_string(types)
|
||||
case _:
|
||||
raise NotImplementedError(format)
|
||||
return annotate
|
||||
|
||||
|
||||
|
|
@ -3229,8 +3232,10 @@ class _TypedDictMeta(type):
|
|||
}
|
||||
elif format == annotationlib.Format.STRING:
|
||||
own = annotationlib.annotations_to_string(own_annotations)
|
||||
else:
|
||||
elif format in (annotationlib.Format.FORWARDREF, annotationlib.Format.VALUE):
|
||||
own = own_checked_annotations
|
||||
else:
|
||||
raise NotImplementedError(format)
|
||||
annos.update(own)
|
||||
return annos
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue