-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Comments
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. |
This is also going to be a problem for Instagram adoption of Black. |
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. |
Reported on the isort end as PyCQA/isort#694. |
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. |
This is compatible with the current black configuration. See : psf/black#127
This is compatible with the current black configuration. See : psf/black#127
This is compatible with the current black configuration. See : psf/black#127
This is compatible with the current black configuration. See : psf/black#127
This is compatible with the current black configuration. See : psf/black#127
It seems that isort is not compatible with black at the moment: psf/black#127 PyCQA/isort#694 Both isort and black are working on a solution, but at the moment, we'll use flake8-import-order instead
It seems that isort is not compatible with black at the moment: psf/black#127 PyCQA/isort#694 Both isort and black are working on a solution, but at the moment, we'll use flake8-import-order instead
It seems that isort is not compatible with black at the moment: psf/black#127 PyCQA/isort#694 Both isort and black are working on a solution, but at the moment, we'll use flake8-import-order instead
hmmm.. hit this issue where |
Added the following to the
|
I also had to add |
has anyone seen this issue pop up again? |
im good with these. |
## Summary Unlike other statements, Black always adds a trailing comma if an import-from statement breaks with a single import member. I believe this is for compatibility with isort -- see psf/black@09f5ee3, psf/black#127, or https://github.com/psf/black/blob/66648c528a95553c1f822ece394ac98784baee47/src/black/linegen.py#L1452 for the current version. ## Test Plan `cargo test`, notice that a big chunk of the compatibility suite is removed. Before: | project | similarity index | |--------------|------------------| | cpython | 0.75472 | | django | 0.99804 | | transformers | 0.99618 | | twine | 0.99876 | | typeshed | 0.74233 | | warehouse | 0.99601 | | zulip | 0.99727 | After: | project | similarity index | |--------------|------------------| | cpython | 0.75472 | | django | 0.99804 | | transformers | 0.99618 | | twine | 0.99876 | | typeshed | 0.74260 | | warehouse | 0.99601 | | zulip | 0.99727 |
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,
would be formatted as
This is probably personal, but this looks a little bit weird. I would suggest this as a better formatting:
The text was updated successfully, but these errors were encountered: