Skip to content

Contributing Style Guide

Oliver Roick edited this page Nov 30, 2015 · 8 revisions

Python

General rules

We write Python3.

We follow PEP8 conventions throughout all our Python code. Key principles include:

  • Always use spaces for indentation. Four spaces make one tab.
  • Maximum line length is 79 characters.
  • Always encode source files in UTF-8.

A few words on strings

Use single quotes for symbol-like strings and double quotes for natural language messages:

MESSAGES = {
    'English': "This organisation has no members.",
    'German':  "Diese Organisation hat keine Mitglieder."
}

Use triple-double quotes for doc strings:

def get_members(self):
    """Returns all members"""
    return self.members

Make interpolated strings readable:

"{org_name} has {num_members} members.".format(
    org_name="Habitat for Humanity",
    num_members=10
)

Never use string concatenation—it makes internationalisation impossible.

Text editors

Use the IDE or text editor you personally prefer.

The repository contains an EditorConfig file, which helps developers maintain consistent coding styles between different editors and IDEs. EditorConfig plugins are available for most editors:

Lint your code using Flake8 for potential errors before committing. Flake8 provider are available for several text editors:

Javascript

Airbnb has pulled together comprehensive ES6 and React guides that we follow for everything JavaScript.

Clone this wiki locally