Skip to content

Add new rule that flags any module that defines public names but doesn't define __all__#24664

Draft
rp-hue wants to merge 1 commit intoastral-sh:mainfrom
rp-hue:rphue/ruf074
Draft

Add new rule that flags any module that defines public names but doesn't define __all__#24664
rp-hue wants to merge 1 commit intoastral-sh:mainfrom
rp-hue:rphue/ruf074

Conversation

@rp-hue
Copy link
Copy Markdown

@rp-hue rp-hue commented Apr 15, 2026

Summary

The PR adds a new rule which checks for modules that export public names without defining __all__, potentially causing namespace polution from from module import *.

Examples that now trigger the rule:

from .connected import *
from ..sibling import *
from . import *

This applies only to init.py.

A key distinction is that absolute wildcard imports are intentionally excluded, as they are already covered by F403.

Does this pull request include references to any relevant issues?

Could not find any issues referencing this, this work was done as part of an internal request.

Test Plan

Tests the aforementioned scenario and additional tests that skips nonwildcard relative exports, absolute imports and if the import has __all__

@rp-hue rp-hue changed the title Add RUF074 [ty] Add new rule that flags any module that defines public names but doesn't define __all__ Apr 15, 2026
@MichaReiser MichaReiser changed the title [ty] Add new rule that flags any module that defines public names but doesn't define __all__ Add new rule that flags any module that defines public names but doesn't define __all__ Apr 16, 2026
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

Successfully merging this pull request may close these issues.

1 participant