Skip to content

carderne/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
  • 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

git clone [email protected]:carderne/postmodern-python.git
cd postmodern-python
pip install -e .

🚀 Usage

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()

🧱 Development

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

🦺 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:

  1. Build it
docker build --tag postmdoern-image .
  1. Run it
docker run --rm -it postmodern-image

# output
# I dunno, start the server or something?

About

A very simple template for productive Python

Resources

License

Stars

Watchers

Forks