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

Method check_arg

mypy/checkexpr.py:2724–2767  ·  view source on GitHub ↗

Check the type of a single argument in a call.

(
        self,
        caller_type: Type,
        original_caller_type: Type,
        caller_kind: ArgKind,
        callee_type: Type,
        n: int,
        m: int,
        callee: CallableType,
        object_type: Type | None,
        context: Context,
        outer_context: Context,
    )

Source from the content-addressed store, hash-verified

2722 )
2723
2724 def check_arg(
2725 self,
2726 caller_type: Type,
2727 original_caller_type: Type,
2728 caller_kind: ArgKind,
2729 callee_type: Type,
2730 n: int,
2731 m: int,
2732 callee: CallableType,
2733 object_type: Type | None,
2734 context: Context,
2735 outer_context: Context,
2736 ) -> None:
2737 """Check the type of a single argument in a call."""
2738 caller_type = get_proper_type(caller_type)
2739 original_caller_type = get_proper_type(original_caller_type)
2740 callee_type = get_proper_type(callee_type)
2741
2742 if isinstance(caller_type, DeletedType):
2743 self.msg.deleted_as_rvalue(caller_type, context)
2744 # Only non-abstract non-protocol class can be given where Type[...] is expected...
2745 elif self.has_abstract_type_part(caller_type, callee_type):
2746 self.msg.concrete_only_call(callee_type, context)
2747 elif not is_subtype(caller_type, callee_type, options=self.chk.options):
2748 error = self.msg.incompatible_argument(
2749 n,
2750 m,
2751 callee,
2752 original_caller_type,
2753 caller_kind,
2754 object_type=object_type,
2755 context=context,
2756 outer_context=outer_context,
2757 )
2758 if not caller_kind.is_star():
2759 # For *args and **kwargs this note would be incorrect - we're comparing
2760 # iterable/mapping type with union of relevant arg types.
2761 self.msg.incompatible_argument_note(
2762 original_caller_type, callee_type, context, parent_error=error
2763 )
2764 if not self.msg.prefer_simple_messages():
2765 self.chk.check_possible_missing_await(
2766 caller_type, callee_type, context, error.code
2767 )
2768
2769 def check_overload_call(
2770 self,

Callers

nothing calls this directly

Calls 12

get_proper_typeFunction · 0.90
is_subtypeFunction · 0.90
isinstanceFunction · 0.85
deleted_as_rvalueMethod · 0.80
concrete_only_callMethod · 0.80
incompatible_argumentMethod · 0.80
is_starMethod · 0.80

Tested by

no test coverage detected