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

Fix ordering for force-sort-within-sections #8665

Merged

Conversation

bluthej
Copy link
Contributor

@bluthej bluthej commented Nov 13, 2023

Fixes #8661

Summary

Imports like from x import y don't have an "asname" for the module, so they were placed before imports like import x as w since None < Some(s) for any string s.
The fix is to first sort by first_alias, since it's None for import x as w, and then by asname.

Test Plan

I included the example from the issue to avoid future regressions.

Imports like `from x import y as z` don't have an "asname" for the
module, so they were placed before imports like `import x as w` since
`None` < `Some(s)` for any string s.
The fix is to first sort by `first_alias` since it's `None` for
`import x as w`.
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Thanks!

@charliermarsh charliermarsh merged commit 23c819b into astral-sh:main Nov 13, 2023
17 checks passed
@charliermarsh charliermarsh added bug Something isn't working isort Related to import sorting labels Nov 13, 2023
@charliermarsh
Copy link
Member

I really appreciate the quick investigation and turnaround here @bluthej.

@bluthej
Copy link
Contributor Author

bluthej commented Nov 14, 2023

Well the regression was due to my refactor so that was the least I could do 😅
Plus it was an easy fix ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working isort Related to import sorting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in Ruff's ordering of import aliases with force-sort-within-sections
2 participants