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

Issue with firstparty/local heading when missing #953

Closed
kingbuzzman opened this issue Jun 3, 2019 · 5 comments
Closed

Issue with firstparty/local heading when missing #953

kingbuzzman opened this issue Jun 3, 2019 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@kingbuzzman
Copy link

My setup.cfg looks like this.

[isort]
# Please keep this in sync with flake8
line_length=120
lines_between_types=1
known_third_party=jq
use_parentheses=True
import_heading_stdlib=Standard imports.
import_heading_django=Django imports.
import_heading_thirdparty=Third-party imports.
import_heading_firstparty=Local imports.
known_django=django
sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
skip_glob=**/migrations/*

I recently came across an issue i hadn't encountered before:

# Third-party imports.
from django_filters import filters
from django_filters.rest_framework import BaseInFilter, FilterSet, NumberFilter

from .models import Inbox

I understand why it didnt put the header -- because i never gave local any header... BUT is there a way i can give localfolder a header IF firstparty is not present. So it looks like this:

# Third-party imports.
from django_filters import filters
from django_filters.rest_framework import BaseInFilter, FilterSet, NumberFilter

# Local imports.
from .models import Inbox

And naturaly when there is a firstparty import not to do the heading:

# Third-party imports.
from django_filters import filters
from django_filters.rest_framework import BaseInFilter, FilterSet, NumberFilter

# Local imports.
from firstparty import func

from .models import Inbox
@DylanYoung
Copy link

A simple implementation would be a --dedup-headings option that if present only includes the heading if it hasn't already been included. This would be sensible to default to true.

DylanYoung added a commit to DylanYoung/isort that referenced this issue Sep 27, 2019
@DylanYoung
Copy link

@timothycrosley Let me know if this draft implementation works for you and I can get some unit tests up and fix that test failure (unrelated to the implementation).

@timothycrosley timothycrosley added the enhancement New feature or request label Jan 7, 2020
@kingbuzzman
Copy link
Author

kingbuzzman commented Feb 18, 2020

@DylanYoung I see the commit, I see your branch, I don't see a PR, can you make a PR? nm #1022 it was closed because of changes requested

@timothycrosley timothycrosley added this to the 5.3.0 milestone Aug 5, 2020
@timothycrosley
Copy link
Member

This is fixed in develop via a new optional --dedup-headings config option and will be deployed with the 5.3.0 release.

Thanks!

~Timothy

@timothycrosley
Copy link
Member

This has now been released to PyPI

Thanks!

~Timothy

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

No branches or pull requests

3 participants