Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ruff to automatically resolve __all__ statements. #11373

Closed
leaver2000 opened this issue May 11, 2024 · 1 comment
Closed

Support for ruff to automatically resolve __all__ statements. #11373

leaver2000 opened this issue May 11, 2024 · 1 comment

Comments

@leaver2000
Copy link

leaver2000 commented May 11, 2024

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.

image

@zanieb
Copy link
Member

zanieb commented May 12, 2024

Hi! I think we're adding what you're looking for in #11314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants