Skip to content

Latest commit

 

History

History
53 lines (31 loc) · 2.02 KB

File metadata and controls

53 lines (31 loc) · 2.02 KB

Python Code Reviews

Python Style Guide

CSE developers follow Google's Python Style Guide. Note the use of strong typing throughout. Older versions of python allow you to get away without this but type checking avoids common errors that are tricky to debug.

Linters

CSE projects should check Python code with automated tools. pylint is the minimum, but we prefer to run three different tools:

Black is a code formatting tool. It removes all need from pycodestyle nagging about formatting so the team can focus on content vs style.

Pyflakes is a fast static analysis tool that identifies common errors in Python code.

PEP 8 is the accepted style guide.

PEP 257 are the encouraged Docstring conventions.

Flake8 is an option for teams who want a single wrapper for running Pyflakes and pycodestyle.

Unit Testing

Unittest is a simple unit testing framework that provides the basics for unit testing: asserts, fixtures, mocks, etc. There is no need to install unittest and tests can be run using:

python -m unittest

Pytest is a simple unit testing framework that provides the basics for unit testing: asserts, fixtures, etc...

pip3 install pytest

Mocking/stubbing framework that works with Pytest. Use this to mock out OS calls, off-box calls, and other calls that would unnecessarily broaden the scope of unit tests.

pip3 install pytest-mock