@@ -6,60 +6,36 @@ The Synapse codebase uses a number of code formatting tools in order to
6
6
quickly and automatically check for formatting (and sometimes logical)
7
7
errors in code.
8
8
9
- The necessary tools are detailed below.
9
+ The necessary tools are:
10
10
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:
12
17
13
18
``` sh
14
19
pip install -e " .[lint,mypy]"
15
20
```
16
21
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.
36
23
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
+ ```
51
27
52
28
It's worth noting that modern IDEs and text editors can run these tools
53
29
automatically on save. It may be worth looking into whether this
54
30
functionality 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.
57
33
58
34
## General rules
59
35
60
36
- ** 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 ` .
63
39
- ** Docstrings** : should follow the [ google code
64
40
style] ( https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings ) .
65
41
See the
0 commit comments