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

Imports are incorrectly sorted after isorting #1048

Closed
mdczaplicki opened this issue Oct 31, 2019 · 3 comments
Closed

Imports are incorrectly sorted after isorting #1048

mdczaplicki opened this issue Oct 31, 2019 · 3 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@mdczaplicki
Copy link

So I've run an isort -rc -y command and after that I isort -rc --check-only and I get to see that some of the files has Imports are incorrectly sorted.

This is part of the code that is being involved:

from products.factories import (
    ProductFactory,
    ProductImageFactory,
    ProductOptionFactory,
    ProductOptionValueFactory,
    ProductPresentmentPriceFactory,
    ProductVariantFactory,
)
from products.models import Product, ProductImage, ProductOption, ProductOptionValue, ProductPresentmentPrice, ProductVariant

from django.test import TestCase

setup.cfg

[isort]
line_length=140
forced_separate=django
multi_line_output=3
balanced_wrapping=True
@Cielquan
Copy link

I have the same problem.
When I apply isort, it adds a new line between 2 third party module imports import click & import tzlocal. And when I then let isort check the file it complains about this line inside the third party category.

My commands are the same.

.isort.cfg

multi_line_output = 3
lines_after_imports = 2
lines_between_types = 1
skip = venv
include_trailing_comma = true```

@Cielquan
Copy link

After I checked the -vb outputs I found out the the recognition of first and third party modules is not working correctly in my case.

I have set neither known_first_party nor known_third_party, but also when I set known_third_party with click and tzlocal the results did not change. This are my outputs:

isort --apply --recursive -vb

else-type place_module for click returned THIRDPARTY
else-type place_module for tzlocal returned FIRSTPARTY

isort --check-only --diff --recursive -vb

else-type place_module for click returned THIRDPARTY
else-type place_module for tzlocal returned THIRDPARTY

Solution for my problem:
Then I noticed that I had set skip_install = True in my tox venv handling the formatting and not set in my venv handling linting.
After I commented the line out and recreated the venv all was ok.

@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