mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-06 04:47:52 +03:00
Changed assignment logic to not specialize class type on RHS to allow for unspecialized type aliases.
This commit is contained in:
parent
30eba9b67d
commit
8875b4d2bf
@ -5504,9 +5504,14 @@ export function createTypeEvaluator(importLookup: ImportLookup): TypeEvaluator {
|
|||||||
const declaredType = getDeclaredTypeForExpression(node.leftExpression);
|
const declaredType = getDeclaredTypeForExpression(node.leftExpression);
|
||||||
|
|
||||||
// Evaluate the type of the right-hand side.
|
// Evaluate the type of the right-hand side.
|
||||||
// An assignment of ellipsis means "Any" within a type stub file.
|
// Don't specialize it in case it's a type alias with no specialized
|
||||||
let srcType = getTypeOfExpression(node.rightExpression, declaredType,
|
// type arguments.
|
||||||
fileInfo.isStubFile ? EvaluatorFlags.ConvertEllipsisToAny : undefined).type;
|
let flags: EvaluatorFlags = EvaluatorFlags.DoNotSpecialize;
|
||||||
|
if (fileInfo.isStubFile) {
|
||||||
|
// An assignment of ellipsis means "Any" within a type stub file.
|
||||||
|
flags |= EvaluatorFlags.ConvertEllipsisToAny;
|
||||||
|
}
|
||||||
|
let srcType = getTypeOfExpression(node.rightExpression, declaredType, flags).type;
|
||||||
|
|
||||||
// Determine if the RHS is a constant boolean expression.
|
// Determine if the RHS is a constant boolean expression.
|
||||||
// If so, assign it a literal type.
|
// If so, assign it a literal type.
|
||||||
|
Loading…
Reference in New Issue
Block a user