@@ -6,60 +6,36 @@ The Synapse codebase uses a number of code formatting tools in order to
66quickly and automatically check for formatting (and sometimes logical)
77errors in code.
88
9- The necessary tools are detailed below.
9+ The necessary tools are:
1010
11- First install them with:
11+ - [ black] ( https://black.readthedocs.io/en/stable/ ) , a source code formatter;
12+ - [ isort] ( https://pycqa.github.io/isort/ ) , which organises each file's imports;
13+ - [ flake8] ( https://flake8.pycqa.org/en/latest/ ) , which can spot common errors; and
14+ - [ mypy] ( https://mypy.readthedocs.io/en/stable/ ) , a type checker.
15+
16+ Install them with:
1217
1318``` sh
1419pip install -e " .[lint,mypy]"
1520```
1621
17- - ** black**
18-
19- The Synapse codebase uses [ black] ( https://pypi.org/project/black/ )
20- as an opinionated code formatter, ensuring all comitted code is
21- properly formatted.
22-
23- Have ` black ` auto-format your code (it shouldn't change any
24- functionality) with:
25-
26- ``` sh
27- black .
28- ```
29-
30- - ** flake8**
31-
32- ` flake8` is a code checking tool. We require code to pass ` flake8`
33- before being merged into the codebase.
34-
35- Check all application and test code with:
22+ The easiest way to run the lints is to invoke the linter script as follows.
3623
37- ` ` ` sh
38- flake8 .
39- ` ` `
40-
41- - ** isort**
42-
43- ` isort` ensures imports are nicely formatted, and can suggest and
44- auto-fix issues such as double-importing.
45-
46- Auto-fix imports with:
47-
48- ` ` ` sh
49- isort .
50- ` ` `
24+ ``` sh
25+ scripts-dev/lint.sh
26+ ```
5127
5228It's worth noting that modern IDEs and text editors can run these tools
5329automatically on save. It may be worth looking into whether this
5430functionality is supported in your editor for a more convenient
55- development workflow. It is not, however, recommended to run `flake8` on
56- save as it takes a while and is very resource intensive.
31+ development workflow. It is not, however, recommended to run ` flake8 ` or ` mypy `
32+ on save as they take a while and can be very resource intensive.
5733
5834## General rules
5935
6036- ** Naming** :
61- - Use camel case for class and type names
62- - Use underscores for functions and variables .
37+ - Use ` CamelCase ` for class and type names
38+ - Use underscores for ` function_names ` and ` variable_names ` .
6339- ** Docstrings** : should follow the [ google code
6440 style] ( https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings ) .
6541 See the
0 commit comments