Skip to content

Relative auto-import top level #4647

Description

@adriengcql

As an enthusiastic user of the auto-import completion, there is one thing I couldn't manage to deal with: when setting the import format to relative ("python.analysis.importFormat": "relative"). there are still cases that need local absolute imports.

For instance in a project with multiple python packages or a separate tests folder:

 - myproject
       - mypackage
            - __init__.py
       -  tests
            - test_foo.py

Importing from mypackage in test_foo.py results in a relative import from ..mypackage import myfunc which is not what is wanted.

In short the idea is to have a way to switch to absolute imports in certain cases, either with some manual configuration or by detecting when the import goes beyond the root of the package.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions