Skip to content

Python

Python Repo Templating

We have a template for creating Python repositories using the cookiecutter package.

dt-template-python-repo

This template provides a standardized structure for Python projects, including:

  • Project structure and organization
  • Configuration files
  • CI/CD pipelines

Usage

Detailed usage instructions are included in the README file of the template repository.

Best practice

uv

Project struture

TODO

Running Code

Always run Python scripts through uv run to ensure reproducible execution with locked dependencies:

# Run scripts
uv run script.py

# Run any command in the uv environment
uv run pytest
Danger

Never use python directly - always prefix with uv run.

Update dependencies

  1. Add/modify dependencies → Edit pyproject.toml
  2. Update lock fileuv lock --upgrade
  3. Sync environmentuv sync

[TODO] write the best practices for python repos

  • linting type checks
  • pipelines
  • dockerfile
  • pieplines/actions/workflows
  • test in pipelines
  • rennovate file
  • nice to have: Makefile
  • cursor rules
  • ruff.toml
  • readme.md * How to fix? * Is it safe to rerun? * How to run locally?