This is awesome, thanks Neil!
I have some suggestions that I think could make it even better:
-
As far as I can tell, this PEP currently does not disallow
def f(): from spam export hamBut this would be desugared into an
__all__within the scope off, which isn’t useful and only confusing. But even if this would have updated the module-level__all__, such dynamic exports would be problematic for static typing.
So I propose we only allowexportstatements to be used at the module-level, for example by having it then raise aSyntaxErrorlike in PEP 842. -
There’s nothing in PEP 843 that mentions or disallows using
exportin anif typing.TYPE_CHECKING:guard. I can imagine that being very useful for type-check-only utilities in stubs packages (notably_typeshed), where an export exists in the stubs but not at runtime. So I think it would help to to mention that this is an intended use-case.