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

Leading space is removed from wrong line #1575

Closed
bersbersbers opened this issue Oct 22, 2020 · 4 comments
Closed

Leading space is removed from wrong line #1575

bersbersbers opened this issue Oct 22, 2020 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@bersbersbers
Copy link

Using v5.6.4:

:/tmp> echo -e "import os\n import os" | isort -

Actual:

mport os
 import os

Expected:

import os
import os

or maybe

import os
 import os
@timothycrosley
Copy link
Member

isort isn't intended to be ran on invalid code, --atomic can be used (at a performance penalty) to ensure the code is valid before being sent to isort to avoid errors like this. Is there a valid code snippet that also triggers this?

@bersbersbers
Copy link
Author

bersbersbers commented Oct 22, 2020

isort isn't intended to be ran on invalid code, --atomic can be used (at a performance penalty) to ensure the code is valid before being sent to isort to avoid errors like this.

I see, and I agree. However, this is the default experience that VS Code users with Python extension are getting. isort is called regardless of whether the code is valid or not, and --atomic leads to an error there.

Is there a valid code snippet that also triggers this?

Not that I am aware of.

@timothycrosley
Copy link
Member

I'm sorry you are experiencing this! I think, if it's okay with you, I might morph this ticket into a more general safety check around isort calls by default. While, I want to avoid a full syntax check like --atomic does (so that isort will maintain compatibility with new versions of Python, even when they are using new syntaxt by default). Maybe there are some light weight checks we can do to avoid the worst outcomes when invalid code is passed in.

@bersbersbers
Copy link
Author

if it's okay with you, I might morph this ticket into a more general safety check around isort calls by default.

Totally - I know how to deal with this, and version control helps in the worst case. This was just a service issue to make isort people aware of it.

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

No branches or pull requests

2 participants