Repository navigation
Allow fine tuning of includeAliasesFromUserFiles #8196
Lukas Lang (lukas-lang)
started this conversation in
Enhancement
Replies: 1 comment
|
Converting into a discussion item for up votes. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I think it would be helpful to have some more options for tuning the behavior related to
python.analysis.includeAliasesFromUserFiles. Imagine the following structure:Assume that each file defines
symbolX(i.e.symbolA,symbolB,...), and that the__init__.pyfiles re-export all symbols viafrom .fileX import symbolX as symbolX.My preferred import style is the following:
More formally, my rule is: Never import from init.py files in any ancestor package of the current file, always import from init.py files in sibling/child packages. The motivation behind this style is that it avoids circular imports, while only using the public interface for everything else, including sibling/child packages.
Currently, the only knob (that I am aware of) is
python.analysis.includeAliasesFromUserFiles: I have to set it totrueto get thefrom ..sub_package2 import ...type imports suggested, but this is too general. In particular:from ..sub_package.fileD import QHBoxLayout, even iffileD.pyimports the symbol asfrom PyQt6.QtWidgets import QHBoxLayout, i.e. not as an alias - it would be helpful if this would be fixed/if there was an option to disable implicit re-exports from being considered. The same semantics are already used for non-user packages, so this would improve consistency.My versions: VS Code: 1.136.1, Pylance: 2026.3.1
All reactions