Description
It's great to see there's a plugin for checking __all__! However, there's a very closely related need: modules that define __all__ should also define __dir__ (Python 3.7+), usually to this:
def __dir__() -> list[str]:
return list(__all__)
This will cause tab completion to only show the public interface of a module, and not imports like annotations and all sorts of other things that are not part of the public interface. See https://learn.scientific-python.org/development/patterns/exports for more info.
I think this check should be split up into two codes; one for normal files, and one for __init__.py files, as implementing a correct __dir__ for __init__.py is harder (it should include submodules that have been imported, doable but more than the one line body above).
What do you think? I could look at adding it if you think it's in scope. Maybe a new three-digit prefix, like DALL101 and DALL102?
Description
It's great to see there's a plugin for checking
__all__! However, there's a very closely related need: modules that define__all__should also define__dir__(Python 3.7+), usually to this:This will cause tab completion to only show the public interface of a module, and not imports like
annotationsand all sorts of other things that are not part of the public interface. See https://learn.scientific-python.org/development/patterns/exports for more info.I think this check should be split up into two codes; one for normal files, and one for
__init__.pyfiles, as implementing a correct__dir__for__init__.pyis harder (it should include submodules that have been imported, doable but more than the one line body above).What do you think? I could look at adding it if you think it's in scope. Maybe a new three-digit prefix, like DALL101 and DALL102?