MCPcopy Create free account
hub / github.com/python/mypy / refine_callable

Function refine_callable

mypy/suggestions.py:1040–1057  ·  view source on GitHub ↗

Refine a callable based on another. See comments for refine_type.

(t: CallableType, s: CallableType)

Source from the content-addressed store, hash-verified

1038
1039
1040def refine_callable(t: CallableType, s: CallableType) -> CallableType:
1041 """Refine a callable based on another.
1042
1043 See comments for refine_type.
1044 """
1045 if t.fallback != s.fallback:
1046 return t
1047
1048 if t.is_ellipsis_args and not is_tricky_callable(s):
1049 return s.copy_modified(ret_type=refine_type(t.ret_type, s.ret_type))
1050
1051 if is_tricky_callable(t) or t.arg_kinds != s.arg_kinds:
1052 return t
1053
1054 return t.copy_modified(
1055 arg_types=[refine_type(ta, sa) for ta, sa in zip(t.arg_types, s.arg_types)],
1056 ret_type=refine_type(t.ret_type, s.ret_type),
1057 )
1058
1059
1060T = TypeVar("T")

Callers 2

get_guessesMethod · 0.85
refine_typeFunction · 0.85

Calls 4

is_tricky_callableFunction · 0.85
refine_typeFunction · 0.85
zipFunction · 0.85
copy_modifiedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…