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

isort 5.5.2 mangles lines that happens to start with from #1488

Closed
wadetregaskis-linkedin opened this issue Sep 18, 2020 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@wadetregaskis-linkedin
Copy link

e.g.:

    raise SomeException("Blah") \
        from exceptionsInfo.popitem()[1]

It transforms it into the gibberish:

    raise SomeException("Blah") \
        from exceptionsInfo.popitem import [1]

isort 4.x didn't do this.

@timothycrosley timothycrosley added the bug Something isn't working label Sep 19, 2020
@timothycrosley
Copy link
Member

@wadetregaskis-linkedin that's a nasty bug! I'll make sure the isort project has a release soon that resolves it and adds additional test cases to ensure it never happens again.

@anirudnits I'm a bit confused about your example? One of the biggest headline features of isort 5 is its ability to sort imports anywhere they are within a file, largely safely: https://pycqa.github.io/isort/docs/major_releases/introducing_isort_5/#sort-imports-anywhere if isort is simply sorting the second import statement that's good! If you encountered any sort of incorrect syntax produced, that of course would be a major bug like the one @wadetregaskis-linkedin raised

Thanks!

~Timothy

@timothycrosley
Copy link
Member

For anyone that runs into this before it is resolved, one option would be to utilize action comments to skip the offending section, since these should be very rare: https://pycqa.github.io/isort/docs/configuration/action_comments/

timothycrosley added a commit that referenced this issue Sep 19, 2020
@anirudnits
Copy link
Collaborator

@timothycrosley sorry my bad :(

@timothycrosley
Copy link
Member

@anirudnits No worries! Just wanted to make sure there wasn't an additional error case of this proportion

@timothycrosley
Copy link
Member

A 5.5.3 hot fix release has just been completed to PyPI that fixes this issue. Confirmed that Python's grammar only allows from to be used for imports, within raise statements, and within yield statements (yield from). Considerable additional testing has been placed around these usages to make sure isort does not mistake them on line continuations as import statements.

Thanks!

~Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants