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

Method check_method_call

mypy/checkexpr.py:4045–4073  ·  view source on GitHub ↗

Type check a call to a method with the given name and type on an object. Return tuple (result type, inferred method type).

(
        self,
        method_name: str,
        base_type: Type,
        method_type: Type,
        args: list[Expression],
        arg_kinds: list[ArgKind],
        context: Context,
    )

Source from the content-addressed store, hash-verified

4043 return make_simplified_union(res), make_simplified_union(meth_res)
4044
4045 def check_method_call(
4046 self,
4047 method_name: str,
4048 base_type: Type,
4049 method_type: Type,
4050 args: list[Expression],
4051 arg_kinds: list[ArgKind],
4052 context: Context,
4053 ) -> tuple[Type, Type]:
4054 """Type check a call to a method with the given name and type on an object.
4055
4056 Return tuple (result type, inferred method type).
4057 """
4058 callable_name = self.method_fullname(base_type, method_name)
4059 object_type = base_type if callable_name is not None else None
4060
4061 # Try to refine the method signature using plugin hooks before checking the call.
4062 method_type = self.transform_callee_type(
4063 callable_name, method_type, args, arg_kinds, context, object_type=object_type
4064 )
4065
4066 return self.check_call(
4067 method_type,
4068 args,
4069 arg_kinds,
4070 context,
4071 callable_name=callable_name,
4072 object_type=base_type,
4073 )
4074
4075 def lookup_operator(self, op_name: str, base_type: Type, context: Context) -> Type | None:
4076 """Looks up the given operator and returns the corresponding type,

Callers 3

check_op_reversibleMethod · 0.95

Calls 3

method_fullnameMethod · 0.95
transform_callee_typeMethod · 0.95
check_callMethod · 0.95

Tested by

no test coverage detected