mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed bug that caused incorrect results with --verifytypes
when NewType
was used to define a type prior to Python 3.9. This addresses https://github.com/microsoft/pyright/issues/4764.
This commit is contained in:
parent
7c23b1afb8
commit
a28fb5d560
@ -20949,16 +20949,20 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
);
|
||||
const callType = baseTypeResult.type;
|
||||
|
||||
if (
|
||||
isInstantiableClass(callType) &&
|
||||
ClassType.isBuiltIn(callType, [
|
||||
'TypeVar',
|
||||
'ParamSpec',
|
||||
'TypeVarTuple',
|
||||
'TypedDict',
|
||||
'NamedTuple',
|
||||
'NewType',
|
||||
])
|
||||
const exemptBuiltins = [
|
||||
'TypeVar',
|
||||
'ParamSpec',
|
||||
'TypeVarTuple',
|
||||
'TypedDict',
|
||||
'NamedTuple',
|
||||
'NewType',
|
||||
];
|
||||
|
||||
if (isInstantiableClass(callType) && ClassType.isBuiltIn(callType, exemptBuiltins)) {
|
||||
isUnambiguousType = true;
|
||||
} else if (
|
||||
isFunction(callType) &&
|
||||
exemptBuiltins.some((name) => callType.details.builtInName === name)
|
||||
) {
|
||||
isUnambiguousType = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user