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

isort: support for from_first setting #8662

Closed
jelmer opened this issue Nov 13, 2023 · 0 comments · Fixed by #8663
Closed

isort: support for from_first setting #8662

jelmer opened this issue Nov 13, 2023 · 0 comments · Fixed by #8663
Labels
isort Related to import sorting

Comments

@jelmer
Copy link
Contributor

jelmer commented Nov 13, 2023

isort has a from_first setting that forces "from .. import .." lines to appear before "import .." lines.

It would be great if ruff could support this too, or something like it. For example:

$ isort --ff true x.py

results in:

from __future__ import annotations

from os import path
import enum
import os
jelmer added a commit to jelmer/ruff that referenced this issue Nov 13, 2023
This setting behaves similarly to the ``from_first`` setting in isort
upstream, and sorts "from X import Y" type imports before straight
imports.

Fixes astral-sh#8662
jelmer added a commit to jelmer/ruff that referenced this issue Nov 13, 2023
This setting behaves similarly to the ``from_first`` setting in isort
upstream, and sorts "from X import Y" type imports before straight
imports.

Fixes astral-sh#8662
@charliermarsh charliermarsh added the isort Related to import sorting label Nov 13, 2023
jelmer added a commit to jelmer/ruff that referenced this issue Nov 16, 2023
This setting behaves similarly to the ``from_first`` setting in isort
upstream, and sorts "from X import Y" type imports before straight
imports.

Fixes astral-sh#8662
charliermarsh pushed a commit that referenced this issue Nov 21, 2023
# Summary

This setting behaves similarly to the ``from_first`` setting in isort
upstream, and sorts "from X import Y" type imports before straight
imports.

Like the other PR I added, happy to refactor if this is better in
another form.

Fixes #8662 

# Test plan

I've added a unit test, and ran this on a large codebase that relies on
this setting in isort to verify it doesn't have unexpected side effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
isort Related to import sorting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants