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

F401 sort bindings before adding to __all__ #11648

Merged
merged 2 commits into from
May 31, 2024
Merged

Conversation

plredmond
Copy link
Contributor

Sort the binding IDs before passing them to the add-to-__all__ function to address #11619.

@plredmond
Copy link
Contributor Author

I ended up sorting the slice rather than the result of the iter/map because that saves a copy. I made the function argument &mut because I figure it's only used in this module. Might be controversial.

Copy link
Contributor

github-actions bot commented May 31, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@@ -330,7 +330,7 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope, diagnostics: &mut
fix_by_reexporting(
checker,
import_statement,
&to_reexport.iter().map(|(b, _)| b).collect::<Vec<_>>(),
&mut to_reexport.iter().map(|(b, _)| b).collect::<Vec<_>>(),
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should just pass in the Vec here, so the ownership is clearer? Then it can be mut imports: Vec<&ImportBinding> and callers don't need to worry about the mutation.

Copy link
Member

Choose a reason for hiding this comment

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

Tweaking this quickly so I can include in the release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! Thanks for explaining

@charliermarsh charliermarsh added the bug Something isn't working label May 31, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) May 31, 2024 20:25
@charliermarsh charliermarsh merged commit e914bc3 into main May 31, 2024
16 checks passed
@charliermarsh charliermarsh deleted the ruff.f401.nondet2 branch May 31, 2024 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants