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

Method is_generic_decorator_overload_call

mypy/checkexpr.py:1402–1419  ·  view source on GitHub ↗

Check if this looks like an application of a generic function to overload argument.

(
        self, callee_type: CallableType, args: list[Expression]
    )

Source from the content-addressed store, hash-verified

1400 return callee
1401
1402 def is_generic_decorator_overload_call(
1403 self, callee_type: CallableType, args: list[Expression]
1404 ) -> Overloaded | None:
1405 """Check if this looks like an application of a generic function to overload argument."""
1406 assert callee_type.variables
1407 if len(callee_type.arg_types) != 1 or len(args) != 1:
1408 # TODO: can we handle more general cases?
1409 return None
1410 if not isinstance(get_proper_type(callee_type.arg_types[0]), CallableType):
1411 return None
1412 if not isinstance(get_proper_type(callee_type.ret_type), CallableType):
1413 return None
1414 with self.chk.local_type_map:
1415 with self.msg.filter_errors():
1416 arg_type = get_proper_type(self.accept(args[0], type_context=None))
1417 if isinstance(arg_type, Overloaded):
1418 return arg_type
1419 return None
1420
1421 def handle_decorator_overload_call(
1422 self, callee_type: CallableType, overloaded: Overloaded, ctx: Context

Callers 1

check_callMethod · 0.95

Calls 5

acceptMethod · 0.95
get_proper_typeFunction · 0.90
lenFunction · 0.85
isinstanceFunction · 0.85
filter_errorsMethod · 0.80

Tested by

no test coverage detected