MCPcopy Index your code
hub / github.com/python/cpython / _get_dunder_annotations

Function _get_dunder_annotations

Lib/annotationlib.py:1144–1165  ·  view source on GitHub ↗

Return the annotations for an object, checking that it is a dictionary. Does not return a fresh dictionary.

(obj)

Source from the content-addressed store, hash-verified

1142
1143
1144def _get_dunder_annotations(obj):
1145 """Return the annotations for an object, checking that it is a dictionary.
1146
1147 Does not return a fresh dictionary.
1148 """
1149 # This special case is needed to support types defined under
1150 # from __future__ import annotations, where accessing the __annotations__
1151 # attribute directly might return annotations for the wrong class.
1152 if isinstance(obj, type):
1153 try:
1154 ann = _BASE_GET_ANNOTATIONS(obj)
1155 except AttributeError:
1156 # For static types, the descriptor raises AttributeError.
1157 return None
1158 else:
1159 ann = getattr(obj, "__annotations__", None)
1160 if ann is None:
1161 return None
1162
1163 if not isinstance(ann, dict):
1164 raise ValueError(f"{obj!r}.__annotations__ is neither a dict nor None")
1165 return ann

Callers 1

get_annotationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…