Style Guidelines

Before contributing code or documentation to the mongorun project, please familiarize yourself with these style guidelines.

Code guidelines

mongorun is not overly prescriptive in terms of style: readability and functionality are the main guiding principles. As a general rule, follow the style used elsewhere in the code and always add meaningful comments.

If you implement a new feature anywhere in mongorun, please write a test function or test class for the feature and document it.

PEP 8

mongorun adheres to most of the standard Python guidelines provided in PEP 8, with the main exception being that mixedCase function and variable names are permitted in order to match usage in MongoDB (for example serverStatus). flake8 is used for style checking.

Import order

To improve readability, imports are sorted alphabetically by type of import. isort is used for import structure checking.

Docstrings (PEP 257)

Please add a descriptive docstring to all new modules, classes, and functions. pydocstyle is used to check docstrings comply with PEP 257.

Documentation guidelines

mongorun documentation is written in reStructuredText and built using Sphinx.

The mongorun documentation uses only standard RST and Sphinx syntax. As a general rule, follow the style used in the rest of the documentation.

Indentation

Indent 3 spaces.

Line length

Limit all lines to 79 characters.

Exceptions:

  • code blocks

  • URLs

Code blocks

Use the code-block directive and specify the language. For example:

.. code-block:: python

   import re