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

Long aliases and use_parentheses generates invalid syntax #957

Closed
mattbennett opened this issue Jun 19, 2019 · 3 comments
Closed

Long aliases and use_parentheses generates invalid syntax #957

mattbennett opened this issue Jun 19, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@mattbennett
Copy link
Contributor

isort with use_parentheses=True inserts parens after the as if the alias is very long.

Example:

from package import module as very_very_very_very_very_very_very_very_very_very_long_alias

results in

from package import (
    module as (
    very_very_very_very_very_very_very_very_very_very_long_alias))

This is not valid syntax.

@EgorChernik
Copy link

The new issue comes))

from package (
    very_long_module_name as nice_alias,
)

line_length doesn't work anymore with that import-construction.

EgorChernik added a commit to EgorChernik/isort that referenced this issue Jun 20, 2019
@mattbennett
Copy link
Contributor Author

@EgorChernik, in ad6af18 you've addressed the second point that I made in my PR: #958

For my usecase (isort combined with black), I actually don't want line-length to be respected in this case. I would argue that the reason use_parentheses exists is to avoid backslashes, so it's not completely obvious to me that this is something that needs fixing.

timothycrosley pushed a commit that referenced this issue Jun 25, 2019
@timothycrosley
Copy link
Member

@mattbennett Thanks for reporting and fixing this issue!

I've pushed a hot fix release that includes your fix: https://github.com/timothycrosley/isort/releases/tag/4.3.21

@EgorChernik this is a good point, long term it may make sense to have a strict line length enforcement setting, to enable nested wrapping like this.

Thanks!

~Timothy

@timothycrosley timothycrosley added the bug Something isn't working label Jun 26, 2019
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