Skip to content

Commit

Permalink
Address review comments 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainpiot committed Oct 25, 2024
1 parent 0c361ba commit 6b04ff3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ 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 && !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
if (shouldResolveImmediately(lazyTypeWrapper, typeFqnParts, i)) {
// We try to resolve the type of the member if it points to a different module.
// If it points to the same module, we try to resolve the submodule of the same name
return typeWrapper.type();
}

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

private static boolean fqnSameAsImportedPath(List<String> typeFqnParts, LazyTypeWrapper lazyTypeWrapper) {
return lazyTypeWrapper.hasImportPath(String.join(".", typeFqnParts));
private static boolean shouldResolveImmediately(LazyTypeWrapper lazyTypeWrapper, List<String> typeFqnParts, int i) {
return i == typeFqnParts.size() - 1 && !(lazyTypeWrapper.hasImportPath(String.join(".", typeFqnParts)));
}

/**
Expand Down

0 comments on commit 6b04ff3

Please sign in to comment.