pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Don't suggest imports from private modules

Open mezuzza opened this issue 6 months ago • 3 comments

Let's say we have the following directory contents:

foo/
  __init__.py
  _bar.py

The contents look like so:

# __init__.py
from ._bar import baz

__all__ = ["baz"]

If I try to import auto-import baz, pyright seems to use from foo._bar import baz and I have to manually change the import. Could we prevent pyright and pylance from suggesting imports from private modules?

For context, I'm using coc-pyright with vim8, so it's totally possible I'm missing something, but I've looked for a while and can't find a good solution to this.

Also, I originally created this question on https://github.com/microsoft/pyright/discussions/8612#discussion-6996652.

mezuzza avatar Aug 19 '24 04:08 mezuzza