mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Correctly calculate qualified name for imported elements (PY-28295)
This commit is contained in:
@@ -243,7 +243,7 @@ public class PyCompatibilityInspection extends PyInspection {
|
||||
}
|
||||
}
|
||||
|
||||
final QualifiedName qName = importElement.getImportedQName();
|
||||
final QualifiedName qName = getImportedFullyQName(importElement);
|
||||
if (qName != null && !qName.matches("builtins") && !qName.matches("__builtin__")) {
|
||||
final String moduleName = qName.toString();
|
||||
|
||||
@@ -254,6 +254,19 @@ public class PyCompatibilityInspection extends PyInspection {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static QualifiedName getImportedFullyQName(@NotNull PyImportElement importElement) {
|
||||
final QualifiedName importedQName = importElement.getImportedQName();
|
||||
if (importedQName == null) return null;
|
||||
|
||||
final PyStatement containingImportStatement = importElement.getContainingImportStatement();
|
||||
final QualifiedName importSourceQName = containingImportStatement instanceof PyFromImportStatement
|
||||
? ((PyFromImportStatement)containingImportStatement).getImportSourceQName()
|
||||
: null;
|
||||
|
||||
return importSourceQName == null ? importedQName : importSourceQName.append(importedQName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyFromImportStatement(PyFromImportStatement node) {
|
||||
super.visitPyFromImportStatement(node);
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
import <warning descr="Python version 3.4, 3.5, 3.6, 3.7 do not have module Bastion">Bastion</warning>
|
||||
import <warning descr="Python version 3.4, 3.5, 3.6, 3.7 do not have module Bastion">Bastion</warning>
|
||||
|
||||
from <warning descr="Python version 2.6, 2.7 do not have module asyncio">asyncio</warning> import Queue
|
||||
from io import StringIO
|
||||
Reference in New Issue
Block a user