A sample Python module skeleton with a modern src/ layout, uv for env/package management, pytest for tests, and ruff for linting/formatting.
This sets up a dev environment inside of docker. Changes made on the host will be immediately reflected.
Pre-reqs: docker
# Download the repo
git clone https://github.com/miketwo/python-skeleton.git
cd python-skeleton
# Build and run the container
docker build -t my_container_name .
docker run -it -v $(pwd):/app my_container_name
# Run tests
./script/test
# Lint/format
./script/lint
./script/format
# Watch tests (rerun automatically on changes)
./script/test-watch
# Console
./script/console
# Now modify a test in `/tests` or the example code in `/src/skeleton/core.py`
# to see the unit tests rerunning. Tada! TDD.
Both python and pytest use caches to speed things up. If you are running the program or tests both inside and outside the container, these caches will conflict can each other. Whenever you switch environments, it's best to clear the cache by:
- Running
find . -name \*.pyc -delete - Using the
--cache-clearoption in pytest or manually deleting__pycache__
Pre-reqs: uv
# Download the repo
git clone https://github.com/miketwo/python-skeleton.git
cd python-skeleton
# Create a virtual environment and install dev deps
./script/setup
# Run tests
./script/test
# Lint/format
./script/lint
./script/format
# Watch tests (rerun automatically on changes)
./script/test-watch
# Now modify a test in `/tests` or the example code in `/src/skeleton/core.py`
# to see the unit tests rerunning. Tada! TDD.
Contributions are welcome! Just submit a PR.
Uses the MIT license.
