@@ -64,6 +64,45 @@ $ cd repos
64
64
$ pip install -e . --config-settings editable_mode=strict
65
65
```
66
66
67
+ ## Linting and Formatting
68
+
69
+ The command ` inv lint ` will lint your changes (using
70
+ [ lint-diffs] ( https://github.com/AtakamaLLC/lint-diffs/ ) ) and ` inv format ` will
71
+ format your changes (using [ darker] ( https://github.com/akaihola/darker ) ). This
72
+ will allow us to incrementally bring this repo up to PEP8 compliance. There is
73
+ [ a CI action] ( .github/workflows/lint.yaml ) to ensure that all new code is
74
+ compliant.
75
+
76
+ To setup the linter commands locally, run the following commands in the root of
77
+ the repository:
78
+
79
+ ``` sh
80
+ # Create a virtual environment
81
+ python -m venv venv
82
+ source venv/bin/activate
83
+ # Install lint dependencies
84
+ pip install -r requirements.lint.txt
85
+ # Run lint
86
+ inv lint
87
+ # Run formatter (will tell you which files it modified)
88
+ inv format
89
+ ```
90
+
91
+ If you get the error ` ERROR:darker.git:fatal: Not a valid commit name <hash> ` ,
92
+ then it's likely because your local main branch is not up to date; either you
93
+ need to rebase or merge. Note that ` darker ` reads from ` pyproject.toml ` for
94
+ default settings.
95
+
96
+ If the lines you change are in a file that uses 2 space indentation, ` darker `
97
+ will indent the lines around your changes and not the rest, which will likely
98
+ break the code; in that case, you should probably just pass the whole file
99
+ through black. You can do that with the following command (using the same
100
+ virtual environment as above):
101
+
102
+ ``` sh
103
+ env/bin/black < file>
104
+ ```
105
+
67
106
# COVIDcast
68
107
69
108
At the present, our primary focus is developing and expanding the
0 commit comments