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

Method check_method_call_by_name

mypy/checkexpr.py:3978–4015  ·  view source on GitHub ↗

Type check a call to a named method on an object. Return tuple (result type, inferred method type). The 'original_type' is used for error messages. The self_type is to bind self in methods (see analyze_member_access for more details).

(
        self,
        method: str,
        base_type: Type,
        args: list[Expression],
        arg_kinds: list[ArgKind],
        context: Context,
        original_type: Type | None = None,
        self_type: Type | None = None,
    )

Source from the content-addressed store, hash-verified

3976 return not is_overlapping_types(left, right, ignore_promotions=False)
3977
3978 def check_method_call_by_name(
3979 self,
3980 method: str,
3981 base_type: Type,
3982 args: list[Expression],
3983 arg_kinds: list[ArgKind],
3984 context: Context,
3985 original_type: Type | None = None,
3986 self_type: Type | None = None,
3987 ) -> tuple[Type, Type]:
3988 """Type check a call to a named method on an object.
3989
3990 Return tuple (result type, inferred method type). The 'original_type'
3991 is used for error messages. The self_type is to bind self in methods
3992 (see analyze_member_access for more details).
3993 """
3994 original_type = original_type or base_type
3995 self_type = self_type or base_type
3996 # Unions are special-cased to allow plugins to act on each element of the union.
3997 base_type = get_proper_type(base_type)
3998 if isinstance(base_type, UnionType):
3999 return self.check_union_method_call_by_name(
4000 method, base_type, args, arg_kinds, context, original_type
4001 )
4002
4003 method_type = analyze_member_access(
4004 method,
4005 base_type,
4006 context,
4007 is_lvalue=False,
4008 is_super=False,
4009 is_operator=True,
4010 original_type=original_type,
4011 self_type=self_type,
4012 chk=self.chk,
4013 in_literal_context=self.is_literal_context(),
4014 )
4015 return self.check_method_call(method, base_type, method_type, args, arg_kinds, context)
4016
4017 def check_union_method_call_by_name(
4018 self,

Calls 6

is_literal_contextMethod · 0.95
check_method_callMethod · 0.95
get_proper_typeFunction · 0.90
analyze_member_accessFunction · 0.90
isinstanceFunction · 0.85

Tested by

no test coverage detected