Skip to content

API Reference

Auto-generated from docstrings using mkdocstrings.

Main

python_template.main

Entry point for python-template.

main()

Run the main application.

This is the CLI entry point configured in pyproject.toml under [project.scripts].

Source code in src/python_template/main.py
def main() -> None:
    """Run the main application.

    This is the CLI entry point configured in ``pyproject.toml``
    under ``[project.scripts]``.
    """
    configure_logging()
    logger.info("Starting python-template")
    print("Hello from python-template!")

Config

python_template.config

Typed configuration using dataclasses.

Field defaults are read from the environment (and a local .env file if present), falling back to the literal defaults below. Values passed explicitly to Config(...) always take precedence over the environment.

Usage

from python_template.config import Config

config = Config() config = Config(seed=42, data_dir="data/processed")

Config dataclass

Project configuration.

Source code in src/python_template/config.py
@dataclass
class Config:
    """Project configuration."""

    # Paths
    data_dir: Path | str = field(default_factory=lambda: _env("DATA_DIR", "data"))
    output_dir: Path | str = field(default_factory=lambda: _env("OUTPUT_DIR", "output"))

    # Reproducibility
    seed: int = field(default_factory=lambda: int(_env("SEED", "42")))

    def __post_init__(self) -> None:
        self.data_dir = Path(self.data_dir)
        self.output_dir = Path(self.output_dir)