Check if the 'other' method can never be matched due to 'signature'. This can happen if signature's parameters are all strictly broader then other's parameters. Assumes that both signatures have overlapping argument counts.
(signature: CallableType, other: CallableType)
| 9139 | |
| 9140 | |
| 9141 | def overload_can_never_match(signature: CallableType, other: CallableType) -> bool: |
| 9142 | """Check if the 'other' method can never be matched due to 'signature'. |
| 9143 | |
| 9144 | This can happen if signature's parameters are all strictly broader then |
| 9145 | other's parameters. |
| 9146 | |
| 9147 | Assumes that both signatures have overlapping argument counts. |
| 9148 | """ |
| 9149 | # The extra erasure is needed to prevent spurious errors |
| 9150 | # in situations where an `Any` overload is used as a fallback |
| 9151 | # for an overload with type variables. The spurious error appears |
| 9152 | # because the type variables turn into `Any` during unification in |
| 9153 | # the below subtype check and (surprisingly?) `is_proper_subtype(Any, Any)` |
| 9154 | # returns `True`. |
| 9155 | # TODO: find a cleaner solution instead of this ad-hoc erasure. |
| 9156 | exp_signature = expand_type( |
| 9157 | signature, {tvar.id: erase_def_to_union_or_bound(tvar) for tvar in signature.variables} |
| 9158 | ) |
| 9159 | return is_callable_compatible( |
| 9160 | exp_signature, other, is_compat=is_more_precise, is_proper_subtype=True, ignore_return=True |
| 9161 | ) |
| 9162 | |
| 9163 | |
| 9164 | def is_more_general_arg_prefix(t: FunctionLike, s: FunctionLike) -> bool: |
no test coverage detected
searching dependent graphs…