Adjustment of auto-import behavior for project-internal imports #3050
smackesey
started this conversation in
Enhancement
Replies: 2 comments 1 reply
-
Did you try defining |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A symbol can be defined in one module and re-exported from several others. When importing a symbol from an external typed library, pylance's behavior is, according to pyright dev @erictraut:
However, this is not the behavior for internal project-internal imports. AFAICT, for project-internal imports, resolution is to the module that defines the symbol, i.e. usually the longest exporting module path is preferred. This can be undesirable on large projects where you have big submodules that you want to provide an "internal public" interface for-- e.g. if you have a large submodule
project.foo
, you might want project-internal code to import only fromproject.foo
itself, rather thanproject.foo.*
submodules.I'd like to suggest that project-internal auto-imports instead resolve to the shortest non-ancestor module that exposes a symbol. So:
Beta Was this translation helpful? Give feedback.
All reactions