Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
howtos:check_python_code [2013/05/20 12:57] – Added flake8 dregad | howtos:check_python_code [2018/08/07 15:51] (current) – add new way of using pylint craynic | ||
---|---|---|---|
Line 4: | Line 4: | ||
- | ===== Using pep8 and pylint ===== | + | ===== Using pycodestyle |
- | The following steps enable you to check your code with Pylint, Pyflakes and Pep8. | + | The following steps enable you to check your code with Pylint, Pyflakes and Pycodestyle (formerly known as pep8). |
Line 18: | Line 18: | ||
#!/bin/sh | #!/bin/sh | ||
- | echo " | + | echo " |
- | pep8 $1 | + | pycodestyle |
echo " | echo " | ||
pyflakes $1 | pyflakes $1 | ||
echo " | echo " | ||
- | pylint --output-format=parseable $1 | + | pylint --msg-template=" |
+ | pylint -f parseable | ||
</ | </ | ||
Line 34: | Line 35: | ||
export PYTHONPATH=" | export PYTHONPATH=" | ||
</ | </ | ||
+ | |||
Line 40: | Line 42: | ||
{{ : | {{ : | ||
- | Open a Python file in Geany or simply create a new file and set the filetype to | + | - Open a Python file in Geany or simply create a new file and set the filetype to Python. |
- | Python. | + | - Open the //Set Build Commands// dialog in the Build menu. |
- | Set for second build command a label, e.g. " | + | - Setup the custom |
+ | * Set a label, e.g. " | ||
+ | * Set the Command field to < | ||
+ | check_python_code %f | ||
+ | </ | ||
+ | - Paste the following text in the "Error regular expression" | ||
+ | ([^:]+): | ||
+ | </ | ||
- | < | ||
- | This assumes that you saved the above mentioned helper script into a path | + | ==== Using pylint |
- | in your $PATH environment variable. If not, just specify the full path | + | |
- | to the script. %f is a placeholder replaced by Geany on execution with | + | |
- | the filename of the current file in the editor. | + | |
- | Then use the following | + | Gösta Ljungdahl mentioned, |
- | field. This regular expression is used by Geany to parse the output of build | + | |
- | commands for errors to be highlighted in the editor. | + | <code dos pylint.bat> |
+ | @echo off | ||
+ | set configfile=c: | ||
+ | echo "====== | ||
+ | c: | ||
+ | </ | ||
- | < | + | Of course, you need to tweak the paths to the config file and pylint.exe. |
+ | The rest should be similar to the explainations above. | ||
Line 90: | Line 101: | ||
- | {{tag> | + | {{tag> |