The last cookiecutter template you'll need.
This repository contains a Cookiecutter template for quickly scaffolding new Python projects with a modern (at the time ;) ) set of development tools and best practices.
The name is a reference to the Hypermodern Python series and its cookiecutter template.
The generated project comes pre-configured with:
- Tool version management managed by Mise using lock files for consistent environments. Manages Python versions and the other tools used in the template.
- Predefined maintenance commands with Mise as well (linting, formatting, testing, etc.).
- Project management using Poetry for dependencies, virtualenvs, etc.
- Linting & formatting provided by Ruff at warp speed.
- Type checking by Basedpyright with Pylance features and improved rules over its parent project.
- Testing employing Pytest for unit/integration testing, with Coverage.py for test coverage reports.
- Git hooks configured via Mise for pre-push checks to give rapid feedback to the developer.
- GitHub Actions CI including a basic Continuous Integration workflow for automated checks.
- Local isolated execution of CI tasks leveraging Act to run your actions in a docker container.
- CLI framework integration (optional) which includes a sample Typer command-line interface structure if opted in during generation.
To use this cookiecutter template to generate a new project:
-
Install Cookiecutter: It is recommended to install
cookiecutterusing pipx, which installs Python applications in isolated environments.pipx install cookiecutter
-
Generate a new project: You can use it directly:
cookiecutter gh:AliGhahraei/post-hypermodern-python-cookiecutter
If you want to clone the repo explicitly, do so and navigate to the directory where you want to create your new project. Afterwards, run the following command, pointing to this repository's directory:
cookiecutter /path/to/repo
Cookiecutter will prompt you for several project-specific details (e.g., project name, author, Python version, whether to include a CLI example).
-
Post-Generation Setup: After you answer the prompts, the template's hook will automatically:
- Initialize a Git repository in your new project (If it's not a repo already).
- Make an initial commit (If it's not a repo already).
- Run
mise run setupto install project dependencies and configure Git hooks.
I use a specific set of tools in my projects nowadays, so I wanted to have my own template and share it in case someone wants to use it someday.