Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python syntax and other things checking?

Tags:

python

I wrote a nice little script to do some lightweight work. I set it to run all night, and when I eagerly checked it this morning, I found that I had left a module name prefix out of one of its variables. Is there any way to check for this kind of chicanery statically? The trouble is that this thing sleeps a lot, so running it isn't the best way to find out.

like image 357
alexgolec Avatar asked Jan 21 '23 03:01

alexgolec


1 Answers

There are three most popular tools: pylint, pyflakes and pycheker.
Pyflakes will show you unused imports, variables, variable usage before assignment, syntax errors and things like that. Pychecker, AFAIK is similar to pyflakes.
Pylint, on the other hand, is a much more comprehensive tool: apart from the listed above, it also checks for PEP8 compatibility, variable names, docstrings, proper indentation, checks for maximum line and module length, number of local variables and class methods and so on. It gives a more or less complete report with a universal score of your code. However, because of the outstanding amount of errors it shows, without proper configuration it is quite tedious to use.

like image 183
allait Avatar answered Feb 07 '23 16:02

allait