mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
PY-18098 Import "numpy" doesn't have effect
ignore same-named modules imported with "asName"
This commit is contained in:
@@ -297,7 +297,7 @@ public class AddImportHelper {
|
||||
for (PyImportElement element : existingImports) {
|
||||
final QualifiedName qName = element.getImportedQName();
|
||||
if (qName != null && name.equals(qName.toString())) {
|
||||
if ((asName != null && asName.equals(element.getAsName())) || asName == null) {
|
||||
if ((asName != null && asName.equals(element.getAsName())) || (asName == null && element.getAsName() == null)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import numpy as np
|
||||
import numpy
|
||||
|
||||
np.ones(3)
|
||||
|
||||
numpy.asarray([1,2,3]) # <-- invoke qfix here
|
||||
5
python/testData/addImport/ignoreImportedAsModule.py
Normal file
5
python/testData/addImport/ignoreImportedAsModule.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
np.ones(3)
|
||||
|
||||
numpy.asarray([1,2,3]) # <-- invoke qfix here
|
||||
@@ -100,6 +100,11 @@ public class PyAddImportTest extends PyTestCase {
|
||||
testLocalImport();
|
||||
}
|
||||
|
||||
// PY-18098
|
||||
public void testIgnoreImportedAsModule() {
|
||||
doAddImport("numpy", THIRD_PARTY);
|
||||
}
|
||||
|
||||
// PY-16373
|
||||
public void testLocalImportQuickFixAvailable() {
|
||||
myFixture.configureByFile(getTestName(true) + ".py");
|
||||
|
||||
Reference in New Issue
Block a user