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

Function join_similar_callables

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

Source from the content-addressed store, hash-verified

762
763
764def 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
785def safe_join(t: Type, s: Type) -> Type:

Callers 1

visit_callable_typeMethod · 0.85

Calls 8

match_generic_callablesFunction · 0.85
rangeClass · 0.85
lenFunction · 0.85
safe_meetFunction · 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…