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

Method analyze_function_body

mypy/semanal.py:1665–1692  ·  view source on GitHub ↗
(self, defn: FuncItem)

Source from the content-addressed store, hash-verified

1663 arg.initializer.accept(self)
1664
1665 def analyze_function_body(self, defn: FuncItem) -> None:
1666 is_method = self.is_class_scope()
1667 fullname = self.function_fullname(defn.fullname)
1668 with self.tvar_scope_frame(self.tvar_scope.method_frame(fullname)):
1669 # Bind the type variables again to visit the body.
1670 if defn.type:
1671 a = self.type_analyzer()
1672 typ = defn.type
1673 assert isinstance(typ, CallableType)
1674 a.bind_function_type_variables(typ, defn)
1675 for i in range(len(typ.arg_types)):
1676 store_argument_type(defn, i, typ, self.named_type)
1677 self.function_stack.append(defn)
1678 with self.enter(defn):
1679 for arg in defn.arguments:
1680 self.add_local(arg.variable, defn)
1681
1682 # The first argument of a non-static, non-class method is like 'self'
1683 # (though the name could be different), having the enclosing class's
1684 # instance type.
1685 if is_method and defn.has_self_or_cls_argument and defn.arguments:
1686 if not defn.is_class:
1687 defn.arguments[0].variable.is_self = True
1688 else:
1689 defn.arguments[0].variable.is_cls = True
1690
1691 defn.body.accept(self)
1692 self.function_stack.pop()
1693
1694 def check_classvar_in_signature(self, typ: ProperType) -> None:
1695 t: ProperType

Callers 2

analyze_func_defMethod · 0.95
visit_lambda_exprMethod · 0.95

Calls 15

is_class_scopeMethod · 0.95
function_fullnameMethod · 0.95
tvar_scope_frameMethod · 0.95
type_analyzerMethod · 0.95
enterMethod · 0.95
add_localMethod · 0.95
store_argument_typeFunction · 0.90
isinstanceFunction · 0.85
rangeClass · 0.85
lenFunction · 0.85
method_frameMethod · 0.80

Tested by

no test coverage detected