(t: CallableType, s: CallableType)
| 815 | |
| 816 | |
| 817 | def combine_similar_callables(t: CallableType, s: CallableType) -> CallableType: |
| 818 | t, s = match_generic_callables(t, s) |
| 819 | arg_types: list[Type] = [] |
| 820 | for i in range(len(t.arg_types)): |
| 821 | arg_types.append(safe_join(t.arg_types[i], s.arg_types[i])) |
| 822 | # TODO kinds and argument names |
| 823 | # TODO what should happen if one fallback is 'type' and the other is a user-provided metaclass? |
| 824 | # The fallback type can be either 'function', 'type', or some user-provided metaclass. |
| 825 | # The result should always use 'function' as a fallback if either operands are using it. |
| 826 | if t.fallback.type.fullname == "builtins.function": |
| 827 | fallback = t.fallback |
| 828 | else: |
| 829 | fallback = s.fallback |
| 830 | return t.copy_modified( |
| 831 | arg_types=arg_types, |
| 832 | arg_names=combine_arg_names(t, s), |
| 833 | ret_type=join_types(t.ret_type, s.ret_type), |
| 834 | fallback=fallback, |
| 835 | name=None, |
| 836 | ) |
| 837 | |
| 838 | |
| 839 | def combine_arg_names( |
no test coverage detected
searching dependent graphs…