initc3 / HoneyBadgerMPC

Robust MPC-based confidentiality layer for blockchains
GNU General Public License v3.0
131 stars 64 forks source link

Require import style as per PEP 8 #392

Closed sbellem closed 4 years ago

sbellem commented 4 years ago

PEP 8 has some guidelines for organizing the imports. One of the key things is:

Imports should be grouped in the following order:

Standard library imports. Related third party imports. Local application/library specific imports.

You should put a blank line between each group of imports.

This structure eases code reviews and provides some consistency for the code base.

You can read more about the reasoning behind the Python Style Guide (PEP 8) in the section: A Foolish Consistency is the Hobgoblin of Little Minds.

Adding the check in Travis CI

The style checker flake8-import-order plugin from the Python Code Quality Authority can be used so that the flake8 check on Travis CI will also check the import style.

The plugin supports multiple styles. The style used by the cryptography project from the Python Cryptographic Authority is the default (see example). This style is more strict than the pep8 style, which "only enforces groups without enforcing the order within the groups". For instance, running the check on the current code base returns 399 errors with the default (cryptography) style and 191 with the pep8 style.

Editor plugins

Some documentation should be added about adding the plugin to the text editor to help developers catching up the errors in their text editor.

sbellem commented 4 years ago

NOTE: Work is under https://github.com/sbellem/HoneyBadgerMPC/tree/pep8-import-order. The branch re-orders the imports as per the cryptography style of flake8-import-order.