Using Flake8 to check your code

Flake8 (http://flake8.pycqa.org/) is another popular tool you can use to verify that your code is correctly formatted. Programming text editors and IDEs that support development generally offer a way to run flake8 as you type, highlighting portions of code that do not match with the flake8 rules.

To install flake8, run the following command:

$ pip install flake8

Here's a flake8 configuration file that was used for the Odoo Community Association development:

[flake8]
# E123,E133,E226,E241,E242 are ignored by default by pep8 and flake8
# F811 is legal in odoo 8 when we implement 2 interfaces for a method
# F999 pylint support this case with expected tests
ignore = E123,E133,E226,E241,E242,F811,F601
max-line-length = 79
exclude = __unported__,__init__.py

Save this in a file called .flake8 at the root of your project, and you should then be able to run the following:

$ flake8 <path_to_file_or_directory>

Better yet, set up your editor to check your code as you type!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset