Shared Python code for GOV.UK Notify applications. Standardises how to do logging, rendering message templates, parsing spreadsheets, talking to external services and more.
This repo is written in Python 3.
We use uv for Python dependency management. Follow the install instructions or run:
curl -LsSf https://astral.sh/uv/install.sh | sh
We use pre-commit to ensure that committed code meets basic standards for formatting, and will make basic fixes for you to save time and aggravation.
Install pre-commit system-wide with, eg brew install pre-commit
. Then, install the hooks in this repository with pre-commit install --install-hooks
.
We use a real Redis instance to test notifications_utils.redis_client.RedisClient
. You can either install locally with brew or run inside a docker container.
The unit test fixture uses FLUSHALL
every single time it is called. To prevent this from having unexpected side effects with a locally running redis instance (e.g. notifications-local) the tests expect redis to run on port 6999. In docker simply change the port mapping flag to -p 6999:6379
. If running outside a container add the flag --port 6999
.
# install dependencies, etc.
make bootstrap
# run the tests
make test
Versioning should be done by running the make version-[type of change]
command, following semantic versioning. For example
make version-patch
Include a short summary (sentence or two) about the changes you've made in CHANGELOG.md
. Please do this even if you're only making a minor or patch version change.
App repos should be updated with the latest version of notifications-utils
where possible. The repos to update are API, Admin, Document Download, Document Download Frontend, Template Preview, Email Stub.
To do this in the app repo:
- Ensure npm, py uv is installed and you're using Python 3.11
- Run
make bootstrap
- Run
make bump-utils
- Run
make freeze-requirements
- Commit with the recommended message and raise a PR.