mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-132426: Add get_annotate_from_class_namespace replacing get_annotate_function (#132490)
As noted on the issue, making get_annotate_function() support both types and mappings is problematic because one object may be both. So let's add a new one that works with any mapping. This leaves get_annotate_function() not very useful, so remove it.
This commit is contained in:
parent
5a57248b22
commit
7cb86c5def
6 changed files with 136 additions and 65 deletions
|
|
@ -2906,7 +2906,7 @@ class NamedTupleMeta(type):
|
|||
types = ns["__annotations__"]
|
||||
field_names = list(types)
|
||||
annotate = _make_eager_annotate(types)
|
||||
elif (original_annotate := _lazy_annotationlib.get_annotate_function(ns)) is not None:
|
||||
elif (original_annotate := _lazy_annotationlib.get_annotate_from_class_namespace(ns)) is not None:
|
||||
types = _lazy_annotationlib.call_annotate_function(
|
||||
original_annotate, _lazy_annotationlib.Format.FORWARDREF)
|
||||
field_names = list(types)
|
||||
|
|
@ -3092,7 +3092,7 @@ class _TypedDictMeta(type):
|
|||
if "__annotations__" in ns:
|
||||
own_annotate = None
|
||||
own_annotations = ns["__annotations__"]
|
||||
elif (own_annotate := _lazy_annotationlib.get_annotate_function(ns)) is not None:
|
||||
elif (own_annotate := _lazy_annotationlib.get_annotate_from_class_namespace(ns)) is not None:
|
||||
own_annotations = _lazy_annotationlib.call_annotate_function(
|
||||
own_annotate, _lazy_annotationlib.Format.FORWARDREF, owner=tp_dict
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue