Skip to content

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

Since 2026.06.0 · Maturity Stable

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 invoke: ⌥⏎ / Alt+Enter"BetterPy: Export symbol to target"

Example

# models.py
class User:
    pass
# models.py
__all__ = ["User"]

class User:
    pass

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.