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

Function combine_similar_callables

mypy/join.py:817–836  ·  view source on GitHub ↗
(t: CallableType, s: CallableType)

Source from the content-addressed store, hash-verified

815
816
817def 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
839def combine_arg_names(

Callers 2

visit_callable_typeMethod · 0.85
visit_overloadedMethod · 0.85

Calls 8

match_generic_callablesFunction · 0.85
rangeClass · 0.85
lenFunction · 0.85
safe_joinFunction · 0.85
combine_arg_namesFunction · 0.85
join_typesFunction · 0.85
appendMethod · 0.80
copy_modifiedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…