Skip to content

Code Style Guide

Kyle Seidenthal edited this page May 11, 2020 · 2 revisions

Code Style Guide

This project follows the PEP8 style guide, with exceptions stated below.

Class Docstrings

Docstrings for classes should describe what the class is for, and list any public attributes:

Class Foo():
'''
A description

Attributes:
    attribute1: Description
    attribute2: Description
'''
...

Function Docstrings

Function docstrings should provide a brief description of their functionality, a list of arguments, return values, and any raised exceptions. For tricky or ambiguous functions, an example is also recommended.

def function(a, b, c):
'''
Do a thing

Args:
    a: A thing
    b: B thing
    c: C thing

Returns:
   Some stuff

Raises:
   An exception if you do the wrong thing.
'''
...

Test functions

For test functions, docstrings do not need to include return values or exceptions, as they generally don't do those things. Instead, a Test Condition should be supplied:

def test_function(setup):
'''
Test a function

Args:
    setup: The setup fixture used to set up the tests

Test Condition:
    a == b  and c < a.
'''
...

Clone this wiki locally