MCPcopy Index your code
hub / github.com/python/mypy / visit_func_def

Method visit_func_def

mypy/stats.py:145–172  ·  view source on GitHub ↗
(self, o: FuncDef)

Source from the content-addressed store, hash-verified

143 self.record_line(imp.line, kind)
144
145 def visit_func_def(self, o: FuncDef) -> None:
146 with self.enter_scope(o):
147 self.line = o.line
148 if len(o.expanded) > 1 and o.expanded != [o] * len(o.expanded):
149 if o in o.expanded:
150 print(
151 "{}:{}: ERROR: cycle in function expansion; skipping".format(
152 self.filename, o.line
153 )
154 )
155 return
156 for defn in o.expanded:
157 assert isinstance(defn, FuncDef)
158 self.visit_func_def(defn)
159 else:
160 if o.type:
161 assert isinstance(o.type, CallableType)
162 sig = o.type
163 arg_types = sig.arg_types
164 if sig.arg_names and sig.arg_names[0] == "self" and not self.inferred:
165 arg_types = arg_types[1:]
166 for arg in arg_types:
167 self.type(arg)
168 self.type(sig.ret_type)
169 elif self.all_nodes:
170 self.record_line(self.line, TYPE_ANY)
171 if not o.is_dynamic() or self.visit_untyped_defs:
172 super().visit_func_def(o)
173
174 @contextmanager
175 def enter_scope(self, o: FuncDef) -> Iterator[None]:

Callers

nothing calls this directly

Calls 8

enter_scopeMethod · 0.95
typeMethod · 0.95
record_lineMethod · 0.95
lenFunction · 0.85
printFunction · 0.85
isinstanceFunction · 0.85
formatMethod · 0.45
is_dynamicMethod · 0.45

Tested by

no test coverage detected