From f588686c427d86863605157571175c77025b6393 Mon Sep 17 00:00:00 2001
From: DMRobertson
The Synapse codebase uses a number of code formatting tools in order to quickly and automatically check for formatting (and sometimes logical) errors in code.
-The necessary tools are detailed below.
-First install them with:
-pip install -e ".[lint,mypy]"
-
+The necessary tools are:
black
-The Synapse codebase uses black -as an opinionated code formatter, ensuring all comitted code is -properly formatted.
-Have black
auto-format your code (it shouldn't change any
-functionality) with:
black .
-
-flake8
-flake8
is a code checking tool. We require code to pass flake8
-before being merged into the codebase.
Check all application and test code with:
-flake8 .
+- black, a source code formatter;
+- isort, which organises each file's imports;
+- flake8, which can spot common errors; and
+- mypy, a type checker.
+
Install them with:
+pip install -e ".[lint,mypy]"
-
-isort
-isort
ensures imports are nicely formatted, and can suggest and
-auto-fix issues such as double-importing.
Auto-fix imports with:
-isort .
+The easiest way to run the lints is to invoke the linter script as follows.
+scripts-dev/lint.sh
-
It's worth noting that modern IDEs and text editors can run these tools
automatically on save. It may be worth looking into whether this
functionality is supported in your editor for a more convenient
-development workflow. It is not, however, recommended to run flake8
on
-save as it takes a while and is very resource intensive.
flake8
or mypy
+on save as they take a while and can be very resource intensive.
CamelCase
for class and type namesfunction_names
and variable_names
.