Skip to content

Fix name resolution in package __init__.py #18159

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robsdedude
Copy link

Summary

When resolving the name while linting a package's __init__.py file, ruff was considering __init__ to be a proper module name. Whereas it's not really. Classes, functions, and other objects defined in __init__.py will belong to the package. This PR fixes that resolution. In particular, D103, and PLW0406 were affected. Maybe more that I couldn't find.

Test Plan

I've added tests for the two rules I could find were affected by not properly resolving qualified names of objects inside a package's __init__.py.

@MichaReiser MichaReiser requested a review from dylwil3 May 18, 2025 16:13
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

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