Files
openide/python/testData/addImport/relativeImportFromAlreadyImportedModule/foo/test.py
Aleksei Kniazev 2d72c69170 relative imports should be inserted instead of absolute ones when possible (PY-6054)
If the file already has relative imports, next one inserted via completion/auto-import has a chance to be relative. For that new import has to have the number of dots <= than the max of the file's relative import and a number provided by a registry value in 'python.relative.import.depth', that is 3 by default. It also has to be located in the same root package, since python doesn't allow relative imports to step outside of it. The file must not have "if __name__ == '__main__'" in it, since it suggests that it is intended to be runnable and relative imports will not work.
Relative import statements can also be updated with new import elements, if the user's codestyle allows it.

GitOrigin-RevId: 766a03e2252bb1f8193a2156831cc8fdf0a7aced
2019-10-02 10:07:03 +00:00

1 line
19 B
Python