A pyproject.toml boilerplate
•
Pythonpyproject.toml
Pyproject.toml boilerplate
Here is an example of boilerplate I might use for a new project.
# Boilerplate pyproject.toml — replace "my-project" and "my_project" with your names.
# See OPERATIONALIZATION.md for how to use this with uv and your workflow.
#
# For a single-module app (e.g. one cli.py at the root), replace the hatch
# packages line with a py-modules or only-include setup; or use setuptools.
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my-project"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []
[dependency-groups]
dev = [
"ruff>=0.15.7",
"ty>=0.0.24",
"rumdl>=0.1.57",
]
test = [
"pytest>=9.0.2",
"pytest-cov>=7.0.0",
]
docs = [
"mkdocs>=1.6.1",
"mkdocs-material>=9.7.6",
"mkdocstrings[python]>=1.0.3",
]
[tool.uv]
default-groups = ["dev", "test", "docs"]
# Hatch wheel build: which packages or modules to include in the built .whl.
#
# — src layout (default): package lives in src/my_project/
# packages = ["src/my_project"]
#
# — Package at project root (my_project/ next to pyproject.toml):
# packages = ["my_project"]
#
# — Single or multiple .py modules at project root:
# only-include = ["cli.py"]
# only-include = ["mod1.py", "mod2.py"]
#
[tool.hatch.build.targets.wheel]
packages = ["src/my_project"]
# For a CLI app, add (adjust module path and callable):
# [project.scripts]
# my-command = "my_project.cli:main"
# ——— Ruff: lint and format (replaces black, isort, flake8) ———
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.lint]
select = ["E", "F", "I", "N", "W", "UP", "B", "C4", "SIM"]
ignore = ["E501"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
# ——— ty: type checking (replaces mypy, pyright) ———
[tool.ty.environment]
python-version = "3.12"
[tool.ty.src]
exclude = ["tests"]
# ——— rumdl: markdown linting (mkdocs flavor) ———
[tool.rumdl]
flavor = "mkdocs"
respect-gitignore = true
disable = ["MD007", "MD013", "MD031", "MD033", "MD046"]
exclude = [".git", ".github", "node_modules", "vendor", "dist", "build", "CHANGELOG.md", "LICENSE.md"]
# ——— Pytest (remove [tool.pytest.ini_options] and the test group if you have no tests) ———
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = ["-v", "--tb=short", "--strict-markers", "--strict-config"]