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

Function nested

Lib/test/test_inspect/inspect_stringized_annotations_pep695.py:55–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53
54
55def nested():
56 from types import SimpleNamespace
57 from inspect import get_annotations
58
59 Eggs = bytes
60 Spam = memoryview
61
62
63 class F[Eggs, **Spam]:
64 x: Eggs
65 y: Spam
66
67 def generic_method[Eggs, **Spam](self, x: Eggs, y: Spam): pass
68
69
70 def generic_function[Eggs, **Spam](x: Eggs, y: Spam): pass
71
72
73 # Eggs is `int` in globals, `bytes` in the function scope,
74 # a TypeVar in the type_params, and `str` in locals:
75 class G[Eggs]:
76 Eggs = str
77 x: Eggs
78
79
80 return SimpleNamespace(
81 F=F,
82 F_annotations=get_annotations(F, eval_str=True),
83 F_meth_annotations=get_annotations(F.generic_method, eval_str=True),
84 G_annotations=get_annotations(G, eval_str=True),
85 generic_func=generic_function,
86 generic_func_annotations=get_annotations(generic_function, eval_str=True)
87 )

Callers 2

runnerMethod · 0.50
coroMethod · 0.50

Calls 1

get_annotationsFunction · 0.85

Tested by 2

runnerMethod · 0.40
coroMethod · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…