Skip to content

Latest commit

 

History

History
103 lines (72 loc) · 2.87 KB

File metadata and controls

103 lines (72 loc) · 2.87 KB

Contributing

Clone

git clone https://github.com/luno/luno-python.git

Create Virtual env

cd luno-python
python -m venv env
source env/bin/activate

Install Dependencies

python -m pip install --upgrade pip setuptools wheel
pip install -e '.[dev]'

This installs the package in editable mode with all development dependencies including testing tools and pre-commit hooks.

Set Up Pre-commit Hooks

This project uses pre-commit to maintain code quality and consistency. The hooks run automatically before commits and pushes.

Install the git hook scripts

pre-commit install

This will run code formatting, linting, security checks, and tests on every commit.

Run hooks manually

To run all hooks on all files manually:

pre-commit run --all-files

What the hooks do

  • Code formatting: Automatically formats code with black and sorts imports with isort
  • Linting: Checks code quality with flake8
  • Security: Scans for common security issues with bandit
  • File checks: Fixes trailing whitespace, ensures files end with newlines, validates YAML/JSON
  • Tests: Runs the full test suite (via pytest)

Skip hooks (use sparingly)

If you need to skip hooks for a specific commit:

git commit --no-verify

Run Tests

pytest

Releasing

This project is published to PyPI. Releases are made by maintainers with repository write access and PyPI publish access.

Steps

  1. Decide the version number following Semantic Versioning:

    • Patch (x.y.Z): backwards-compatible bug fixes
    • Minor (x.Y.0): new backwards-compatible functionality
    • Major (X.0.0): breaking changes
  2. Bump the version in luno_python/__init__.py:

    VERSION = "x.y.z"
  3. Commit and push the version bump on a branch, then open and merge a PR:

    git checkout -b release-x.y.z
    git add luno_python/__init__.py
    git commit -m "release: bump version to x.y.z"
    git push origin release-x.y.z
    gh pr create --title "release: bump version to x.y.z" --body "Bump version for release."
    # After review, merge the PR
  4. Create a GitHub Release from the merged commit on main:

    git checkout main && git pull origin main
    gh release create vx.y.z --title "vx.y.z" --generate-notes

    This triggers the publishing workflow, which automatically builds and uploads the package to PyPI.

PyPI Trusted Publishing

The publishing workflow uses PyPI Trusted Publishing (OpenID Connect), which means no API tokens need to be stored as secrets. This must be configured once in PyPI's project settings under Publishing → Add a new publisher, pointing at this repository's publish.yml workflow.