Configure code checking and formatting tools

Checking
- mypy
- flake8 (which uses pyflakes and pycodestyle)

Formatting
- autopep8
- isort
This commit is contained in:
Joscha 2021-05-16 14:31:43 +02:00
parent 8b76ebb3ef
commit 3efec53f51
5 changed files with 37 additions and 9 deletions

25
DEV.md
View File

@ -15,12 +15,14 @@ environment, run these commands in the same directory as this file:
```
$ python -m venv .venv
$ . .venv/bin/activate
$ pip install --editable .
$ ./scripts/setup
```
After this, you can use PFERD as if it was installed normally. Since PFERD was
installed with `--editable`, there is no need to re-run `pip install` when the
source code is changed.
The setup script installs a few required dependencies and tools. It also
installs PFERD via `pip install --editable .`, which means that you can just run
`pferd` as if it was installed normally. Since PFERD was installed with
`--editable`, there is no need to re-run `pip install` when the source code is
changed.
For more details, see [this part of the Python Tutorial][venv-tut] and
[this section on "development mode"][ppug-dev].
@ -29,9 +31,22 @@ For more details, see [this part of the Python Tutorial][venv-tut] and
[venv-tut]: <https://docs.python.org/3/tutorial/venv.html> "12. Virtual Environments and Packages"
[ppug-dev]: <https://packaging.python.org/guides/distributing-packages-using-setuptools/#working-in-development-mode> "Working in “development mode”"
## Checking and formatting the code
To run a set of checks against the code, run `./scripts/check` in the repo's
root directory. This script will run a few tools installed by `./scripts/setup`
against the entire project.
To format the code, run `./scripts/format` in the repo's root directory.
Before committing changes, please make sure the checks return no warnings and
the code is formatted.
## Contributing
When submitting a PR that adds, changes or modifies a feature, please ensure
that the corresponding documentation is updated.
that the corresponding documentation is updated as well. Also, please ensure
that `./scripts/check` returns no warnings and the code has been run through
`./scripts/format`.
In your first PR, please add your name to the `LICENSE` file.

4
scripts/check Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
mypy PFERD
flake8 PFERD

4
scripts/format Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
autopep8 --recursive --in-place PFERD
isort PFERD

5
scripts/setup Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
pip install --upgrade pip setuptools
pip install --editable .
pip install --upgrade mypy flake8 autopep8 isort

View File

@ -15,8 +15,8 @@ install_requires =
console_scripts =
pferd = PFERD.__main__:main
[pycodestyle]
max-line-length = 110
[flake8]
max_line_length = 110
[pylint.FORMAT]
max-line-length = 110
[isort]
line_length = 110