mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed a bug that led to the incorrect evaluation of a symbol imported through a from a.b import c
statement if a.b
is a non-py.typed library, useLibraryCodeForTypes is false and c
was also the name of a submodule of a.b. In this case, the evaluated type of c
should be Unknown
, but it was incorrectly evaluated as a module type. This addresses https://github.com/microsoft/pyright/issues/4827.
This commit is contained in:
parent
903fd3cee3
commit
cca8ce8a41
@ -44,6 +44,17 @@ export function resolveAliasDeclaration(
|
||||
|
||||
while (true) {
|
||||
if (curDeclaration.type !== DeclarationType.Alias || !curDeclaration.symbolName) {
|
||||
// If this is an alias with a path, perform the lookup to see if
|
||||
// we can resolve it. If not, it's probably referencing a source file
|
||||
// that we are not analyzing (e.g. a non-py.typed library source file
|
||||
// when useLibraryCodeForTypes is disabled).
|
||||
if (curDeclaration.type === DeclarationType.Alias && curDeclaration.path) {
|
||||
const lookupResult = importLookup(curDeclaration.path);
|
||||
if (!lookupResult) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
declaration: curDeclaration,
|
||||
isPrivate,
|
||||
|
Loading…
Reference in New Issue
Block a user