A very simple template for productive Python.
This template pulls together most of the advice and ideas from this blog post, which explains the choices in more detail:
Beyond Hypermodern: Python is easy now
It includes the following bits:
- Rye for Python, virtual env, dependency management and script running
- Ruff for formatting and linting (replaces isort, flake, isort etc)
- Pyright for type checking (set to strict mode, but do what makes you happy)
- Pytest for tests
- A Github Actions workflows for formatting/linting/checking/testing PRs/merges
- Another for releasing to PyPI
- A basic Dockerfile for running in a container
- Some basic Python snippets to get you started
- coverage
- The rest of this README!
- Hit the green
Use this template
button up on the right next to the stars - Give your new repository a name and then clone it to your dev environment.
- Rename it:
./rename.sh your-cool-new-name
- Run
rye sync
- Have a look at the stuff below here, try out some commands and edit this README as you like!
assumes you have Rye installed for development (installation instructions at the link).
git clone [email protected]:carderne/postmodern-python.git
cd postmodern-python
rye sync; # Install Python and dependencies
source .venv/bin/activate
From the command line:
python -m postmodern # thanks to __main__.py
# or
postmodern # thanks to pyproject.toml, project.scripts
Format, lint, typecheck etc:
rye run fmt
lint
check # runs pyright
test
all # runs all the above sequentially
look at Makefile for quick examples.
# generate code coverage
make rye.coverage
make rye.coverage.report
This has Github Actions setup for Pull Requests and for Release to PyPI.
-
The pr.yml workflow will run on any new Pull Request. Change some code, open a PR and wait for teh green tick!
-
The release.yml is for releasing packages to PyPI. It is currently set up to to run only when you create a new Release. But you can change that!
It also has a Dockerfile that you can try out as follows:
look at Makefile for quick examples.
# build image
make docker.build
# run container
make docker.run