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
- 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!
git clone [email protected]:carderne/postmodern-python.git
cd postmodern-python
pip install -e .
From the command line:
python -m postmodern # thanks to __main__.py
# or
postmodern # thanks to pyproject.toml, project.scripts
From Python:
from postmodern import hello
hello()
Using Rye for development (installation instructions at the link).
Install Python and dependencies:
rye sync
Format, lint, typecheck etc:
rye run fmt
lint
check
test
all # runs all the above sequentially
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:
- Build it
docker build --tag postmdoern-image .
- Run it
docker run --rm -it postmodern-image
# output
# I dunno, start the server or something?