Support for ruff to automatically resolve `__all__` statements.
leaver2000 opened this issue · comments
It would be very useful and appreciated if there was an option to have ruff
automatically resolve the __all__
statement. A configuration might look something like...
[tool.ruff]
auto-all = ["**/__init__.py"]
From the pep regarding __all__
.
To better support introspection, modules should explicitly declare the names in their public API using the
__all__
attribute. Setting all to an empty list indicates that the module has no public API.
That fix might look something like.
Module level “dunders” should be placed after the module docstring but before any import statements except from future imports module-level-dunder-names
# app/__init__.py
"""docstring"""
from .core import my_function
running something along the lines of ruff check auto-all="**/__init__.py" --fix app
would result in...
# app/__init__.py
"""docstring"""
__all__ = ["my_function"]
from .core import my_function
Take this example from the dask/array/__init__.py
where the __all__
is not set and the resulting complaint from pylance
.
Hi! I think we're adding what you're looking for in #11314