You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Do not export imported names in stubs unless using 'as' #453
If a stub for module x imports something from typing, for example, currently from x import * also imports that name, which is wrong, since generally the module implementation does not import anything from typing, and besides it's just a bad idea in general.
However, we don't want to define __all__ for every stub, as that would be painful and redundant, since stubs mostly contain only exported features. Maybe we should not export any imported names by default, unless the import uses as. For example:
fromtypingimportList# Not exportedimportos.pathaspath# Exportedimportosasos# Also exported
This would only affect stubs. We need a way of knowing which files are stubs. Initially, just anything that is under stubs/ should be considered a stub.
Sorry, I disagree here. import os as os is unexpected. __all__ is verbose but at least people expect and understand it (hopefully?). Also, the fact that as was used is unavailable during runtime which might or might not be relevant in the future, for instance when somebody tries to implement runtime checks.
Activity
ambv commentedon Jan 8, 2015
Sorry, I disagree here.
import os as osis unexpected.__all__is verbose but at least people expect and understand it (hopefully?). Also, the fact thataswas used is unavailable during runtime which might or might not be relevant in the future, for instance when somebody tries to implement runtime checks.gvanrossum commentedon Jan 8, 2015
See my counter-proposal regarding
__all__in python/typing#22 (comment)JukkaL commentedon May 17, 2015
We'll use the approach linked to in Guido's comment instead.
JukkaL commentedon Aug 17, 2015
Update: We are back to using
as: python/typing@4215e09Also, now we can detect stubs easily as they use the
.pyiextension, so this should be straightforward to implement.