|
20 | 20 | TupleType, TypedDictType, Instance, TypeVarType, ErasedType, UnionType, |
21 | 21 | PartialType, DeletedType, UninhabitedType, TypeType, TypeOfAny, LiteralType, |
22 | 22 | true_only, false_only, is_named_instance, function_type, callable_type, FunctionLike, |
23 | | - StarType, is_optional, remove_optional, is_invariant_instance |
| 23 | + StarType, is_optional, remove_optional, is_generic_instance |
24 | 24 | ) |
25 | 25 | from mypy.nodes import ( |
26 | 26 | NameExpr, RefExpr, Var, FuncDef, OverloadedFuncDef, TypeInfo, CallExpr, |
@@ -885,13 +885,13 @@ def infer_function_type_arguments_using_context( |
885 | 885 | # variables in an expression are inferred at the same time. |
886 | 886 | # (And this is hard, also we need to be careful with lambdas that require |
887 | 887 | # two passes.) |
888 | | - if isinstance(ret_type, TypeVarType) and not is_invariant_instance(ctx): |
| 888 | + if isinstance(ret_type, TypeVarType) and not is_generic_instance(ctx): |
889 | 889 | # Another special case: the return type is a type variable. If it's unrestricted, |
890 | 890 | # we could infer a too general type for the type variable if we use context, |
891 | 891 | # and this could result in confusing and spurious type errors elsewhere. |
892 | 892 | # |
893 | 893 | # Give up and just use function arguments for type inference. As an exception, |
894 | | - # if the context is an invariant instance type, actually use it as context, as |
| 894 | + # if the context is a generic instance type, actually use it as context, as |
895 | 895 | # this *seems* to usually be the reasonable thing to do. |
896 | 896 | # |
897 | 897 | # See also github issues #462 and #360. |
|
0 commit comments