(t: CallableType, s: CallableType)
| 762 | |
| 763 | |
| 764 | def join_similar_callables(t: CallableType, s: CallableType) -> CallableType: |
| 765 | t, s = match_generic_callables(t, s) |
| 766 | arg_types: list[Type] = [] |
| 767 | for i in range(len(t.arg_types)): |
| 768 | arg_types.append(safe_meet(t.arg_types[i], s.arg_types[i])) |
| 769 | # TODO in combine_similar_callables also applies here (names and kinds; user metaclasses) |
| 770 | # The fallback type can be either 'function', 'type', or some user-provided metaclass. |
| 771 | # The result should always use 'function' as a fallback if either operands are using it. |
| 772 | if t.fallback.type.fullname == "builtins.function": |
| 773 | fallback = t.fallback |
| 774 | else: |
| 775 | fallback = s.fallback |
| 776 | return t.copy_modified( |
| 777 | arg_types=arg_types, |
| 778 | arg_names=combine_arg_names(t, s), |
| 779 | ret_type=join_types(t.ret_type, s.ret_type), |
| 780 | fallback=fallback, |
| 781 | name=None, |
| 782 | ) |
| 783 | |
| 784 | |
| 785 | def safe_join(t: Type, s: Type) -> Type: |
no test coverage detected
searching dependent graphs…