Skip to content

gsiawGH/postmodern-python

 
 

Repository files navigation

postmodern-python

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!

🤔 How to use this template

  1. Hit the green Use this template button up on the right next to the stars
  2. Give your new repository a name and then clone it to your dev environment.
  3. Rename it:
./rename.sh your-cool-new-name
  1. Run rye sync
  2. Have a look at the stuff below here, try out some commands and edit this README as you like!

💾 Installation

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

🚀 Usage

From the command line:

python -m postmodern  # thanks to __main__.py
# or
postmodern  # thanks to pyproject.toml, project.scripts

🧱 Development

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 

🦺 CI/CD

This has Github Actions setup for Pull Requests and for Release to PyPI.

  1. The pr.yml workflow will run on any new Pull Request. Change some code, open a PR and wait for teh green tick!

  2. 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!

Docker

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

About

A very simple template for productive Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 58.2%
  • Dockerfile 24.0%
  • Makefile 17.8%