Refine a callable based on another. See comments for refine_type.
(t: CallableType, s: CallableType)
| 1038 | |
| 1039 | |
| 1040 | def 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 | |
| 1060 | T = TypeVar("T") |
no test coverage detected
searching dependent graphs…