PY-36374 When suggesting imports, don't shadow package aliases with namesake definitions

Previously, we suggested variants for these well-known aliases only if no
other symbols were found. In particular, having "np" name defined in the
sources of pandas prevented "import numpy as np" from being offered.

ImportCandidateHolder had to be refactored a bit to keep the name of
the corresponding symbol itself, because it used to be taken from the parent
AutoImportQuickFix, which now only holds the name of the reference, and, thus,
"numpy" ended up being imported as "import np as np".

Also, such imports are now suggested higher in the list than the rest.

GitOrigin-RevId: 75bed654431e81e6df40f1400ee4b02a4ab0dcca
This commit is contained in:
Mikhail Golubev
2021-01-06 11:57:23 +03:00
committed by intellij-monorepo-bot
parent dd3bf6e195
commit 3ba2747c51
12 changed files with 95 additions and 54 deletions

View File

@@ -0,0 +1 @@
<error descr="Unresolved reference 'np'">n<caret>p</error>.ndarray

View File

@@ -0,0 +1,3 @@
import numpy as np
np.ndarray