Skip to content

Prioritize attribute in from/import statement#15041

Merged
dcreager merged 6 commits intomainfrom
dcreager/more-from-imports
Dec 17, 2024
Merged

Prioritize attribute in from/import statement#15041
dcreager merged 6 commits intomainfrom
dcreager/more-from-imports

Conversation

@dcreager
Copy link
Member

This tweaks the new semantics from #15026 a bit when a symbol could be interpreted both as an attribute and a submodule of a package. For from...import, we should actually prioritize the attribute, because of how the statement itself is implemented:

  1. check if the imported module has an attribute by that name
  2. if not, attempt to import a submodule with that name and then check the imported module again for that attribute

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@dcreager dcreager merged commit e8e461d into main Dec 17, 2024
@dcreager dcreager deleted the dcreager/more-from-imports branch December 17, 2024 21:58
@dhruvmanila dhruvmanila added the ty Multi-file analysis & type inference label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants