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

add_imports option is broken #651

Closed
fyber opened this issue Feb 1, 2018 · 7 comments
Closed

add_imports option is broken #651

fyber opened this issue Feb 1, 2018 · 7 comments

Comments

@fyber
Copy link

fyber commented Feb 1, 2018

Just installed new version of isort=4.3.0 (on python 3.6).
Given this file (itest.py):

from __future__ import absolute_import, unicode_literals

VAR = """
multiline text
"""

and this config in setup.cfg:

[isort]
add_imports =
    from __future__ import absolute_import
    from __future__ import unicode_literals

when I run isort itest.py I got this result:

from __future__ import absolute_import, unicode_literals

VAR = """
multiline text
"""

from __future__ import unicode_literals
from __future__ import absolute_import

When I run same command one more time the result is like this:

from __future__ import absolute_import, unicode_literals

VAR = """
multiline text
"""

from __future__ import unicode_literals
from __future__ import absolute_import

from __future__ import absolute_import
from __future__ import unicode_literals

If I remove VAR from that file and run isort again, the result is as expected:

from __future__ import absolute_import, unicode_literals

I believe this is a regression as I was unable to reproduce it in version 4.2.15.
This bug makes new version unusable for us, since we have files with multiline strings and add_imports setting.

@adamchainz
Copy link
Contributor

Also seeing this when upgrading in adamchainz/django-mysql#424

@timothycrosley
Copy link
Member

This should now be fixed in release 4.3.1, Thank you!

@fyber
Copy link
Author

fyber commented Feb 3, 2018

I'm sorry, but looks like this is not fixed in version 4.3.1.
Output is the same as in my example above.

@adamchainz
Copy link
Contributor

I'm afraid I'm also still seeing the same, updated my previously linked PR

timothycrosley added a commit that referenced this issue Feb 3, 2018
@timothycrosley timothycrosley reopened this Feb 3, 2018
timothycrosley added a commit that referenced this issue Feb 3, 2018
@timothycrosley
Copy link
Member

I'm so sorry! I didn't merge the fix in correctly before distributing the new release to PYPI, this should now be resolved in 4.3.2

@adamchainz
Copy link
Contributor

Works for me thanks!

@adamchainz
Copy link
Contributor

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

No branches or pull requests

3 participants