|
|
## pylint config
|
|
|
|
|
|
We use [pylint](https://pylint.readthedocs.io/en/latest/), a standard tool to check code quality in Python.
|
|
|
|
|
|
We adopt the [standard configuration proposed by the Python extension Visual Studio Code](https://code.visualstudio.com/docs/python/linting#_default-pylint-rules) and enrich it with some custom [pylint features](https://pylint.readthedocs.io/en/latest/technical_reference/features.html) like `unused-import`.
|
|
|
|
|
|
The same `pylintrc` file is shared by all the developers.
|
|
|
|
|
|
First, clone the [code-style](https://git.nomics.world/dbnomics/code-style) repository.
|
|
|
|
|
|
For each project (fetcher, API, data-model, etc.), configure your editor to call pylint with the following option: `--rcfile /path/to/code-style/pylintrc`. For example, in Visual Studio Code, the configuration is done by adding the following key to `.vscode/settings.json`:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"python.linting.pylintArgs": [
|
|
|
"--rcfile", "/path/to/code-style/pylintrc"
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### autopep8 config
|
|
|
|
|
|
To make autopep8 (auto formatting Python code tool) coherent with Pylint settings, you can add these line to VScode settings:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"python.formatting.autopep8Args": [
|
|
|
"--max-line-length=120"
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### VScode config
|
|
|
|
|
|
VScode can also visually indicates the max line length by adding in settings:
|
|
|
|
|
|
```json
|
|
|
"[python]": {
|
|
|
"editor.rulers": [
|
|
|
120
|
|
|
],
|
|
|
"editor.formatOnSave": true,
|
|
|
// See https://github.com/Microsoft/vscode/issues/46678#issuecomment-383755763
|
|
|
"editor.codeActionsOnSave": {
|
|
|
"source.organizeImports": true
|
|
|
}
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
See https://git.nomics.world/dbnomics/code-style |
|
|
\ No newline at end of file |