I moved the custom index lookup, previously used in PyImportCollector to find
modules and packages, to PyModuleNameIndex, already utilized in other similar,
places such as PyModulePackageCompletionContributor. Two new methods where
introduced to the interface of PyModuleNameIndex for that. The first one
is a generalization of find(), allowing to re-use an existing search scope, and
the second finds modules by their fully qualified name in the same fashion as
it was done in PyClassNameIndex.findClass().
GitOrigin-RevId: 2de5821351eacf08ddc045454eea189b21fa1186
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
items defined in the project > items from the standard library > items from other libraries
doesn't start or end with _ > starts with _ > starts with _ > starts and ends with __
items with no leading _ in import path > with leading _ in import path
function/variable/class > module/directory
less items in the import path > more items in the import path
GitOrigin-RevId: 7fba600668d7f7eab4dbd5d3891811cfe2501b89
Interestingly, this new code style option affects the text of the auto import
quickfix since the latter reflects whether a symbols will be imported anew or
by extending some existing import.
even when some existing imports offer the name in question, as
quite often multiple stdlib and third-party modules define
the same name.
I've also restored functionality PyAddImportQuickFixTest after recent
changes in it that precluded checks of individual import candidates.