What to use for finding as many syntax errors as possible.

Cameron Simpson cs at cskk.id.au
Mon Oct 10 04:50:38 EDT 2022


On 10Oct2022 09:04, Antoon Pardon <antoon.pardon at vub.be> wrote:
>>It is easy to get the syntax right before submitting to such a 
>>pipeline.  I usually run a linter on my code for serious commits, and 
>>I've got a `lint1` alias which basicly runs the short fast flavour of 
>>that which does a syntax check and the very fast less thorough lint 
>>phase.
>
>If you have a linter that doesn't quit after the first syntax error, 
>please provide a link. I already tried pylint and it also quits after 
>the first syntax error.

I don't have such a linter. I did outline an approach for you to write 
one of your own by wrapping an existing parser program.

I have a personal "lint" script which runs a few linters. The first 
check is `py_compile` which quits at the first syntax error. The other 
linters are not even tried if that fails.

I do not know what your editing environment is; I'd have thought that 
some IDEs should make the first syntax error very obvious and easy to go 
to, and an obvious indication that the file as a whoe is syntacticly 
good/bad. If you have such, between them you could fairly easily resolve 
syntax errors rapidly, perhaps rapidly enough to make up for a 
stop-at-the-first-fail syntax check.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list