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

How to use import_headings option? #2110

Closed
yozachar opened this issue Mar 20, 2023 · 4 comments
Closed

How to use import_headings option? #2110

yozachar opened this issue Mar 20, 2023 · 4 comments

Comments

@yozachar
Copy link

yozachar commented Mar 20, 2023

In my pyproject.toml I have:

[tool.isort]
ensure_newline_before_comments = true
force_grid_wrap = 0
force_sort_within_sections = true
import_headings = { STDLIB = "standard", THIRDPARTY = "external", FIRSTPARTY = "local" }
include_trailing_comma = true
length_sort = true
line_length = 100
multi_line_output = 3
reverse_sort = true
reverse_relative = true
use_parentheses = true

Actual Output

from urllib.parse import urlsplit
from functools import lru_cache
import re

import pytest

from .hostname import hostname
from .utils import validator

Expected Output

# standard
from urllib.parse import urlsplit
from functools import lru_cache
import re

# external
import pytest

# local
from .hostname import hostname
from .utils import validator

What am I missing?

@yozachar
Copy link
Author

yozachar commented Mar 20, 2023

Documentation does not provide an example.


Can we enable reverse_sort only for length?

@anirudnits
Copy link
Collaborator

anirudnits commented Mar 20, 2023

Hello @joe733, thanks for raising this issue! I looked into it and it turns out you have to declare the headings like this:

import_heading_stdlib = "standard"
import_heading_thirdparty = "external"
import_heading_firstparty = "local"

and it would do the trick. I do understand that there isn't adequate documentation surrounding this and I would take up the task to add this in the docs.

Let me know if you have any other concerns.

@yozachar
Copy link
Author

Hi @anirudnits, that worked!

import_heading_stdlib = "standard"
import_heading_thirdparty = "external"
import_heading_localfolder = "local"

Thank you. Do you want to keep this issue (labeled question/documentation) open? Or shall I close it?

@anirudnits
Copy link
Collaborator

Glad I could help! I'm closing this ticket as I've opened another one #2111 to improve doc support and also have raised a PR for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants