coala / coala-bears

Bears for coala
https://coala.io/
GNU Affero General Public License v3.0
295 stars 580 forks source link

Add a PythonSyntaxBear that only complains about syntax errors #753

Open underyx opened 8 years ago

underyx commented 8 years ago

It's probably possible to use the builtin ast module for this.

Or maybe https://github.com/PyCQA/astroid or https://github.com/davidhalter/jedi

gitmate-bot commented 8 years ago

Thanks for reporting this issue! A coalaian will look at it soon.

jayvdb commented 8 years ago

Would you consider pyflakes acceptable? It also reports unused import/variable, but generally stays strictly away from style issues.

sils commented 8 years ago

:+1: if it does the job

underyx commented 8 years ago

Maybe if we can add the possibility of a syntax_only = yes option. I'd like to give people with crappy codebases the ability to start using coala with useful checks without changing a single line of code.

On Wed, Sep 14, 2016, 5:21 PM Lasse Schuirmann notifications@github.com wrote:

👍 if it does the job

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/coala-analyzer/coala-bears/issues/753#issuecomment-247049556, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAuVPq0qKBMMNHwQyd0Mr0604liwWlWks5qqBEDgaJpZM4JyEhW .

jayvdb commented 8 years ago

Nod. I expected you were wanting a less noisy tool. We would need to filter the pyflakes output to achieve that, and it is a reasonable request.

Jedi linting is still unstable, but looks like a serious option anyway. I suspect astroid is not much better than the ast module at detecting SyntaxError's.

jayvdb commented 7 years ago

@sadovnychyi, do you have an idea on how good/stable jedi is now at identifying syntax errors. I havent played with it very much, and it was a while ago, so I could be very wrong.

sadovnychyi commented 7 years ago

@jayvdb No idea, sorry. AFAIK Jedi just ignores syntax errors if possible. I'm not aware of any APIs which would allow to only check the syntax.

Citation from here:

You might ask now: "Why didn't you use the ``ast``
module for this? Well, ``ast`` does a very good job understanding proper Python
code, but fails to work as soon as there's a single line of broken code.

Seems like the whole idea of Jedi's custom parser is to ignore any possible syntax errors.

jayvdb commented 7 years ago

There is a new release of pylint and astroid, which should stablise quickly. That might be worth investigating.

But, IMO it is worth-while improving PyflakesBear to add syntax_only = yes which ignores the various error codes which are not syntax related, or maybe just reduce the severity of results that are not errors.