Set up Python project with pyproject.toml, ruff, mypy, pre-commit, and uv
You are helping the user set up a Python project with modern tooling and Infiquetra standards.
For a new Infiquetra Python project, create this structure:
project-name/
├── src/
│ └── service/
│ ├── __init__.py
│ └── handler.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ └── unit/
│ └── __init__.py
├── pyproject.toml
├── .pre-commit-config.yaml
├── .gitignore
├── README.md
└── .python-version (optional)
Start with the minimal template from references/pyproject-template.md:
[project]
name = "your-service-name"
version = "0.1.0"
description = "Your service description"
requires-python = ">=3.12"
dependencies = [
"boto3>=1.34.0",
"aws-lambda-powertools>=2.30.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-cov>=4.1.0",
"ruff>=0.2.0",
"mypy>=1.8.0",
"moto[all]>=5.0.0",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.lint]
select = ["E", "F", "I", "N", "W", "B", "C4", "UP"]
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--cov=src --cov-report=html --cov-fail-under=80"
[tool.mypy]
python_version = "3.12"
disallow_untyped_defs = true
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or with homebrew
brew install uv
# Verify installation
uv --version
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install project with dev dependencies
uv pip install -e ".[dev]"
# Or with standard pip
pip install -e ".[dev]"
Create .pre-commit-config.yaml (see references/pre-commit-config.md):
default_language_version:
python: python3.12