This project uses the PEP 8 – Style Guide for Python Code as coding convention, with the following customization:
- Code line length: 88
- Use double quotes as default (don't mix and match for simple quoting, checked with pylint).
- Configuration:
pyproject.tomlfor pylint and isortsetup.cfgfor flake8
Install all code linting tools:
pip3 install -r requirements.txt -r test-requirements.txtNote: once pypa/pip#11440 is implemented, the requirements files can be removed and
pyproject.toml is sufficient.
python3 -m pylint ucapi- The tool is configured in
.pylintrc.
Linting integration in PyCharm/IntelliJ IDEA:
- Install plugin Pylint
- Open Pylint window and run a scan:
Check ModuleorCheck Current File
Import statements must be sorted with isort:
python3 -m isort ucapi/.- The tool is configured in
pyproject.tomlto use theblackcode-formatting profile.
Source code is formatted with the Black code formatting tool:
python3 -m black ucapiPyCharm/IntelliJ IDEA integration:
- Go to
Preferences or Settings -> Tools -> Black - Configure:
- Python interpreter
- Use Black formatter:
On code reformat& optionallyOn save
The following tests are run as GitHub action for each push on the main branch and for pull requests. They can also be run anytime on a local developer machine:
python3 -m pylint ucapi
python3 -m flake8 ucapi --count --show-source --statistics
python3 -m isort ucapi/. --check --verbose
python3 -m black ucapi --check --verbose