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

Option to sort imports in isort-like order? #1302

Closed
sunshowers opened this issue Feb 9, 2017 · 3 comments
Closed

Option to sort imports in isort-like order? #1302

sunshowers opened this issue Feb 9, 2017 · 3 comments

Comments

@sunshowers
Copy link

Python's isort tool sorts imports with the following order:

  • Future
  • Python Standard Library
  • Third Party
  • Current Python Project
  • Explicitly Local (. before import, as in: from . import x)
  • Custom Separate Sections (Defined by forced_separate list in configuration file)

Could rustfmt gain an option somewhere to reorder imports with similar rules?

@eira-fransham
Copy link

eira-fransham commented Aug 16, 2017

I would love this if there were newlines between each group. I was about to file a request for a regroup_imports option that would do this exact thing. My suggestion would be:

  • core and std
  • Absolute (normal imports), including built-in crates like test
  • super and self

Plus, this could group extern crate definitions seperately too.

EDIT: Looks like this is in the works already, pretty-much following the suggestion I've made here rust-lang/style-team#24

@sanmai-NL
Copy link

Very useful indeed. Can this issue be closed in favor of #298 though?

@nrc nrc added the duplicate label Sep 24, 2017
@nrc
Copy link
Member

nrc commented Sep 24, 2017

Yeah, let's track in #298

@nrc nrc closed this as completed Sep 24, 2017
github-merge-queue bot pushed a commit to NomicFoundation/slang that referenced this issue Dec 8, 2023
Part of #155 

This is fairly standard practice - we group the imports in the `std` >
external libraries > current crate categories, separated by newlines.

Some links:
- rust-lang/style-team#24
- rust-lang/rustfmt#1302
- https://www.reddit.com/r/rust/comments/wwbxhw/comment/ilkid50/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants