Install Python lint tools on Mac
Lint tools is the code format and style checker.
Before I introduce one nice lint tools, I will introduce one easy way to check Python code.
py_compile
There is one easy way to check python code before running Python code.
This comand is such as `perl -c perl_code.pl`
$ python -m py_compile your_python_code.py
I am using this command by alias.
$ vi ~/.bashrc ... alias pythonc='python -m py_compile'
$ pythonc your_python_code.py
hacking
Install "hacking" module.
openstack-dev/hacking · GitHub
$ pip install hacking
$ flake8 your_python_code.py
This "hacking" module's command will check your code by below styles, by following very strict rule.
- PEP8 Style
https://www.python.org/dev/peps/pep-0008/
- PEP257 Style
https://www.python.org/dev/peps/pep-0257/
- OpenStack Style Guidelines
http://docs.openstack.org/developer/hacking/
- pyflakes (Check unused variable, unused import, and etc)