basedmypy
basedmypy copied to clipboard
An `export` annotation that works at runtime
Maintaining __all__ is extremely painful, what about an export decorator (not sure about attributes though)
def export(fn: Fn) -> Fn:
mod = fn.__module__
if hasattr(mod, "__all__"):
isinstance(mod.__all__, list):
mod.__all__.append(fn.__name__)
else:
mod.__all__ = [fn.__name__]