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

Local and third party packages are being sorted together #1104

Closed
Siecje opened this issue Jan 16, 2020 · 3 comments
Closed

Local and third party packages are being sorted together #1104

Siecje opened this issue Jan 16, 2020 · 3 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@Siecje
Copy link
Contributor

Siecje commented Jan 16, 2020

I am using develop but local imports and third party imports are being sorted together.

~/.isort.cfg

[settings]
known_third_party=gcutilities
force_sort_within_sections=1
no_lines_before=LOCALFOLDER
order_by_type=False
cody@ ~/D/why> tree
.
├── baz.py
└── Platform
    ├── foo.py
    └── __init__.py
cody@ ~/D/why> cat Platform/foo.py 
bar = 1

cody@ ~/D/why> cat baz.py 
from rest_framework import serializers

from Platform.foo import bar

cody@ ~/D/why> isort baz.py 
Fixing /home/cody/Desktop/why/baz.py
cody@ ~/D/why> cat baz.py 
from Platform.foo import bar
from rest_framework import serializers
@toumorokoshi
Copy link

I've noticed this as well. I don't see any clear documentation on isort's sort inference strategy, but isort is effectively looking to see if a package is installed to determine if it's first or third party.

For example, if I don't install flask into my virtualenv, it's considered a first party and sorted with the rest.

If I do install flask, it's considered a third party.

It might be better in general for isort to have an uncategorized section. But at least documenting this behavior somewhere easily accessible would have saved me a lot of time.

@toumorokoshi
Copy link

Also it looks like #1071 is a good solution for this.

@timothycrosley
Copy link
Member

This should be fixed for the 5.0.0 release in spirit via this ticket: #1147

@timothycrosley timothycrosley added duplicate This issue or pull request already exists enhancement New feature or request labels Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants