Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainpiot committed Oct 24, 2024
1 parent a3760b4 commit 0c361ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public PythonType getType(List<String> typeFqnParts) {
if (parent instanceof ModuleType moduleType) {
TypeWrapper typeWrapper = moduleType.members().get(part);
if (typeWrapper instanceof LazyTypeWrapper lazyTypeWrapper && !lazyTypeWrapper.isResolved()) {
if (i == typeFqnParts.size() - 1 && !(lazyTypeWrapper.hasImportPath(String.join(".", typeFqnParts)))) {
// this is the name we are looking for, resolve it
if (i == typeFqnParts.size() - 1 && !fqnSameAsImportedPath(typeFqnParts, lazyTypeWrapper)) {
// this is the name we are looking for and its imported path is not the one we are trying to find, resolve it
return typeWrapper.type();
}

Expand All @@ -91,6 +91,10 @@ public PythonType getType(List<String> typeFqnParts) {
return parent;
}

private static boolean fqnSameAsImportedPath(List<String> typeFqnParts, LazyTypeWrapper lazyTypeWrapper) {
return lazyTypeWrapper.hasImportPath(String.join(".", typeFqnParts));
}

/**
* This method returns a module type for a given FQN, or unknown if it cannot be resolved.
* It is to be used to retrieve modules referenced in the "from" clause of an "import from" statement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class lib: ...
}

@Test
void resolveCustomStub() {
void resolveStubsWithImportedModuleVariableDescriptor() {
var symbolTable = ProjectLevelSymbolTable.empty();
var table = new ProjectLevelTypeTable(symbolTable);

Expand Down

0 comments on commit 0c361ba

Please sign in to comment.