Check if this looks like an application of a generic function to overload argument.
(
self, callee_type: CallableType, args: list[Expression]
)
| 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 |
no test coverage detected