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

Method visit_func_def

mypy/semanal.py:959–986  ·  view source on GitHub ↗
(self, defn: FuncDef)

Source from the content-addressed store, hash-verified

957 #
958
959 def visit_func_def(self, defn: FuncDef) -> None:
960 self.statement = defn
961
962 # Visit default values because they may contain assignment expressions.
963 for arg in defn.arguments:
964 if arg.initializer:
965 arg.initializer.accept(self)
966
967 defn.is_conditional = self.block_depth[-1] > 0
968
969 # Set full names even for those definitions that aren't added
970 # to a symbol table. For example, for overload items.
971 defn._fullname = self.qualified_name(defn.name)
972
973 # We don't add module top-level functions to symbol tables
974 # when we analyze their bodies in the second phase on analysis,
975 # since they were added in the first phase. Nested functions
976 # get always added, since they aren't separate targets.
977 if not self.recurse_into_functions or len(self.function_stack) > 0:
978 if not defn.is_decorated and not defn.is_overload:
979 self.add_function_to_symbol_table(defn)
980
981 if not self.recurse_into_functions and not defn.def_or_infer_vars:
982 return
983
984 with self.scope.function_scope(defn), self.set_recurse_into_functions():
985 with self.inside_except_star_block_set(value=False):
986 self.analyze_func_def(defn)
987
988 def function_fullname(self, fullname: str) -> str:
989 if self.current_overload_item is None:

Callers

nothing calls this directly

Calls 8

qualified_nameMethod · 0.95
analyze_func_defMethod · 0.95
lenFunction · 0.85
function_scopeMethod · 0.80
acceptMethod · 0.45

Tested by

no test coverage detected