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

ALEFix deletes all content if you have syntax errors #706

Closed
mpacer opened this issue Jun 28, 2017 · 1 comment
Closed

ALEFix deletes all content if you have syntax errors #706

mpacer opened this issue Jun 28, 2017 · 1 comment
Labels

Comments

@mpacer
Copy link

mpacer commented Jun 28, 2017

This was an interesting bug to encounter, if you have syntactically invalid code, running ALEFix with yapf as the only fixer results in deleting all content from the file.

Here's a really simplified example derived from the case I ran into this with:

def test_nosource_with_output:
    cell = {'cell_type': 'code', 'execution_count': 2, 'metadata': {}, 'outputs': [{'name': 'stdout', 'output_type': 'stream', 'text': 'hi\n'}], 'source': ''}

It's more startling to see that happen with more code in a file, but my guess is that this is undesired behaviour no matter how terrible the error.

Note: yapf doesn't do this on the command line if you run it on an invalid file, it just returns a SyntaxError.

@w0rp w0rp added the bug label Jun 29, 2017
@w0rp w0rp closed this as completed in 518f99b Jun 29, 2017
@w0rp
Copy link
Member

w0rp commented Jun 29, 2017

I have fixed this now.

Now any fixer which runs with an asynchronous job which returns empty output will be skipped. I figure there's just about nothing which will fix problems in a file by returning no output at all, and if you really want to fix a file that way, you can just delete every line in the file yourself.

I'll figure out some way to report errors from jobs later. For yapf, it's obvious, as the linters will tell you about syntax errors.

w0rp added a commit that referenced this issue Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants