Code quality checks example for students
Table of Contents
Setup project
Install Poetry and Invoke
This project uses invoke and poetry to speed up the process.
You need to install them only once.
The simplest way to get both is to install poetry first, with the officially recommended way:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
You may need to run following command then:
echo 'export PATH="$PATH:$HOME/.poetry/bin"' >> $HOME/.zshrc
(Check out alternative instructions for poetry installation
here)
After that poetry is able to automatically
provide you with invoke installed in the project virtual env.
So you can do one of following task:
# Run it directly
poetry run inv [task]
# Run it from the virtual environment
poetry shell
inv [task]
# Have an alias (use custom name to avoid clashing with `inv` and `invoke`)
alias invv='poetry run inv'
invv [task]
An alternative way to install all tools is using pipx:
python3.7 -m pip install pipx --user
pipx install poetry
pipx install invoke
Setup Virtual Environment
Run poetry install to install or re-install all dependencies.
Now you should have fully setup local environment to run the project.
If needed: run poetry update to update the locked dependencies to the most recent
version, honoring the constrains put inside pyproject.toml.
Automated Tasks
Run tests
Run code quality checks
poetry run inv check-code
Run safety checks for project libraries
poetry run inv check-safety