Ensures that the callable's type variables are 'detached' and independent of the context. A callable normally keeps track of the type variables it uses within its 'variables' field. However, if the callable is from a method and that method is using a class type variable, the callable wi
(typ: CallableType, class_type_vars: list[TypeVarLikeType])
| 9126 | |
| 9127 | |
| 9128 | def detach_callable(typ: CallableType, class_type_vars: list[TypeVarLikeType]) -> CallableType: |
| 9129 | """Ensures that the callable's type variables are 'detached' and independent of the context. |
| 9130 | |
| 9131 | A callable normally keeps track of the type variables it uses within its 'variables' field. |
| 9132 | However, if the callable is from a method and that method is using a class type variable, |
| 9133 | the callable will not keep track of that type variable since it belongs to the class. |
| 9134 | """ |
| 9135 | if not class_type_vars: |
| 9136 | # Fast path, nothing to update. |
| 9137 | return typ |
| 9138 | return typ.copy_modified(variables=list(typ.variables) + class_type_vars) |
| 9139 | |
| 9140 | |
| 9141 | def overload_can_never_match(signature: CallableType, other: CallableType) -> bool: |
no test coverage detected
searching dependent graphs…