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

Wrapping imports is incompatible with isort #127

Closed
zenozen opened this issue Apr 12, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@zenozen
Copy link

commented Apr 12, 2018

Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:

Operating system: Mac OS X 10.13.4
Python version: 3.6.5
Black version: 18.4a1
Does also happen on master: Yes

For example,

from django.http import HttpResponse, HttpResponseBadRequest, JsonResponse, HttpResponse, HttpRequest

would be formatted as

from django.http import (
    HttpResponse, HttpResponseBadRequest, JsonResponse, HttpResponse, HttpRequest
)

This is probably personal, but this looks a little bit weird. I would suggest this as a better formatting:

from django.http import (
    HttpRequest,
    HttpResponse,
    HttpResponseBadRequest,
    JsonResponse,
)
@zenozen

This comment has been minimized.

Copy link
Author

commented Apr 12, 2018

To add a bit of context, I'm trying to make black work with isort. But it seems that black's formatting style is not among isort's list of multi-line output modes (https://github.com/timothycrosley/isort#multi-line-output-modes).

This creates a problem. When I save my python file, it's formatted with black, but isort (flake8-isort) would complain about incorrectly formatted imports, which basically put my code in a bad state.

@carljm

This comment has been minimized.

Copy link
Collaborator

commented Apr 12, 2018

This is also going to be a problem for Instagram adoption of Black.

@ambv

This comment has been minimized.

Copy link
Collaborator

commented Apr 13, 2018

This form of wrapping lines applies to all code in Black. Making an exception for imports alone is inconsistent, especially if motivated purely by another, optional tool for Black users.

I'm talking to @timothycrosley about introducing "multiline mode 8" in isort which would enable both tools to peacefully co-exist. I hope this works, if not, we'll think of other options.

@ambv ambv changed the title Imports with parentheses should be per-line with trailing comma Wrapping imports is incompatible with isort Apr 13, 2018

@ambv

This comment has been minimized.

Copy link
Collaborator

commented Apr 13, 2018

Reported on the isort end as timothycrosley/isort#694.

@ambv ambv removed the not a bug label Apr 24, 2018

@ambv

This comment has been minimized.

Copy link
Collaborator

commented Apr 24, 2018

Due to Timothy's silence on the isort end I decided to change how we're formatting imports to be compatible with his valuable tool.

@ambv ambv closed this in 09f5ee3 Apr 24, 2018

@mar10 mar10 referenced this issue Oct 3, 2018

Merged

Cleanup #132

Pierre-Sassoulas added a commit to Pierre-Sassoulas/generic-python-project that referenced this issue Nov 18, 2018

blaggacao added a commit to xoe-labs/dockery-odoo-scaffold that referenced this issue Mar 1, 2019

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Mar 9, 2019

Feat - Add isort in the pre-commit configuration
This is compatible with the current black configuration.
See : python/black#127

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Mar 9, 2019

Feat - Add isort in the pre-commit configuration
This is compatible with the current black configuration.
See : python/black#127

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Mar 9, 2019

Feat - Add isort in the pre-commit configuration
This is compatible with the current black configuration.
See : python/black#127

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Mar 19, 2019

Feat - Add isort in the pre-commit configuration
This is compatible with the current black configuration.
See : python/black#127

PCManticore added a commit to PyCQA/pylint that referenced this issue Mar 20, 2019

Feat - Add isort in the pre-commit configuration
This is compatible with the current black configuration.
See : python/black#127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.