PY-19773 Remember already suggested importable elements using their canonical names
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Wed, 29 Jun 2016 21:44:18 +0000 (00:44 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Thu, 30 Jun 2016 05:50:59 +0000 (08:50 +0300)
commit1c3b81b322e064bf365cf1d4490b499ae40bbe52
tree845467cc926f0a5a03d67f54d30941336887722a
parent4c7872332c6a2685e51247f882c601a900218ea3
PY-19773 Remember already suggested importable elements using their canonical names

The problem was caused by the fact that we ignore imported element
"request" in "flask/__init__.py" at first and mark this module as
already checked (using the name "flask") and then refuse to suggest
"flask.globals.requests" because its canonical qualified name is
"flask.request".

I've also added a test on importing functions of os.path module since
it's a well-known case where several different symbols should be imported
using the same name (provided by PyStdlibCanonicalPathProvider).
My first attempt to fix the problem by saving actual import candidates
instead of their canonical qualified names has broken exactly this
scenario.
13 files changed:
python/src/com/jetbrains/python/codeInsight/imports/AutoImportQuickFix.java
python/src/com/jetbrains/python/codeInsight/imports/ImportCandidateHolder.java
python/src/com/jetbrains/python/codeInsight/imports/PythonImportUtils.java
python/testData/quickFixes/AddImportQuickFixTest/osPathFunctions/main.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/osPathFunctions/main_after.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/osPathFunctions/ntpath.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/osPathFunctions/os.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/osPathFunctions/posixpath.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/reexportedName/flask/__init__.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/reexportedName/flask/globals.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/reexportedName/main.py [new file with mode: 0644]
python/testData/quickFixes/AddImportQuickFixTest/reexportedName/main_after.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/quickFixes/AddImportQuickFixTest.java [new file with mode: 0644]