Imports & Module Boundaries¶
BetterPy helps you manage Python module boundaries — exporting symbols, enforcing import conventions, and keeping source root prefixes consistent.
Export Symbol to Target¶
Exports a symbol to a specified target module's __all__ list.
How to invoke: ⌥⏎ / Alt+Enter → "BetterPy: Export symbol to target"
Unexport Symbol¶
Removes a symbol from __all__ and its corresponding import.
How to invoke: ⌥⏎ / Alt+Enter → "BetterPy: Unexport symbol"
Relative Import Preference¶
Prefers relative imports over absolute imports when applicable. When auto-importing, BetterPy will suggest relative imports within the same package.
Source Roots¶
Export symbol to target¶
Export symbol to target adds a selected top-level symbol to another module's public API by updating the chosen target file's __all__ export list.
How to use it¶
Place the caret on a top-level class, function, or variable and run the intention from Alt+Enter. If more than one export target is available, choose the target module or package __init__.py file when BetterPy asks where the symbol should be exported.
Notes¶
- The intention updates or creates
__all__in the chosen target file. - When the chosen target is a different module, BetterPy also inserts the relative re-export import.
- Targets that already export the symbol are shown as already exported in the chooser.
- It is gated by the Export symbol to target setting.