mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-09 13:35:59 +03:00
Added logic to better handle the case where a symbol is defined multiple times with a TypeAlias
declaration. This is an error condition, but it does occur in some stdlib type stubs if pyright is configured to use "All" for the "pythonPlatform" setting.
This commit is contained in:
parent
ee8f7c21d6
commit
006541d053
@ -18684,9 +18684,18 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
});
|
||||
}
|
||||
|
||||
let sawExplicitTypeAlias = false;
|
||||
decls.forEach((decl, index) => {
|
||||
let considerDecl = declIndexToConsider === undefined || index === declIndexToConsider;
|
||||
|
||||
// If we have already seen an explicit type alias, do not consider
|
||||
// additional decls. This can happen if multiple TypeAlias declarations
|
||||
// are provided -- normally an error, but it can happen in stdlib stubs
|
||||
// if the user sets the pythonPlatform to "All".
|
||||
if (sawExplicitTypeAlias) {
|
||||
considerDecl = false;
|
||||
}
|
||||
|
||||
if (usageNode !== undefined) {
|
||||
if (decl.type !== DeclarationType.Alias) {
|
||||
// Is the declaration in the same execution scope as the "usageNode" node?
|
||||
@ -18704,6 +18713,10 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
const isExplicitTypeAlias = isExplicitTypeAliasDeclaration(decl);
|
||||
const isTypeAlias = isExplicitTypeAlias || isPossibleTypeAliasDeclaration(decl);
|
||||
|
||||
if (isExplicitTypeAlias) {
|
||||
sawExplicitTypeAlias = true;
|
||||
}
|
||||
|
||||
// If this is a type alias, evaluate it outside of the recursive symbol
|
||||
// resolution check so we can evaluate the full assignment statement.
|
||||
if (
|
||||
|
Loading…
Reference in New Issue
Block a user