Fixed false positive error when a generic class with a ParamSpec type parameter implements a descriptor protocol.

This commit is contained in:
Eric Traut 2021-09-28 19:18:51 -07:00
parent 7fff1f89ad
commit 3d75f5b41a
2 changed files with 7 additions and 2 deletions

View File

@ -4530,11 +4530,16 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
boundMethodType &&
(isFunction(boundMethodType) || isOverloadedFunction(boundMethodType))
) {
const typeVarMap = new TypeVarMap(getTypeVarScopeId(boundMethodType));
if (bindToClass) {
typeVarMap.addSolveForScope(getTypeVarScopeId(bindToClass));
}
const callResult = validateCallArguments(
errorNode,
argList,
boundMethodType,
/* typeVarMap */ undefined,
typeVarMap,
/* skipUnknownArgCheck */ true
);

View File

@ -72,4 +72,4 @@ class B:
b = B()
t_b1: Literal["str"] = reveal_type(b.foo)
t_b2: Literal["Minimal[~B, str]"] = reveal_type(B.foo)
t_b2: Literal["Minimal[B, str]"] = reveal_type(B.foo)