[build-system]
requires = ["hatchling>=1.21"]
build-backend = "hatchling.build"

[project]
name = "{{ cookiecutter.project_slug }}"
version = "0.1.0"
description = "{{ cookiecutter.description }}"
readme = "README.md"
requires-python = ">={{ cookiecutter.python_version }}"
license = { text = "{{ cookiecutter.license }}" }
authors = [
    { name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.author_email }}" },
]
dependencies = [
    "mgf-common{{ cookiecutter.mgf_common_pin }}",
]

[project.optional-dependencies]
dev = [
    "pytest>=8.0",
    "pytest-cov>=5.0",
    "ruff>=0.4",
    "mypy>=1.10",
    "import-linter>=2.0",
]

[tool.hatch.build.targets.wheel]
packages = ["src/{{ cookiecutter.package_name }}"]

# ----------------------------------------------------------------------
# Package distribution — resolve everything from the self-hosted devpi index
# (docs/standards/PACKAGE_DISTRIBUTION.md §6, rules PKG-01/PKG-06).
#
# mgf-* packages AND third-party deps resolve from the self-hosted devpi
# index (magogi/prod): it serves the private mgf-* packages and mirrors
# public PyPI. A SINGLE default index means there is no second index for a
# public package to shadow an mgf-* sibling from, so dependency-confusion is
# structurally impossible, and TRANSITIVE mgf-* deps resolve correctly (uv
# does NOT apply [tool.uv.sources] pins to transitive deps, so the old
# explicit-pin design broke on e.g. mgf-common[standards] -> mgf-standard).
#
# devpi is anonymous-read — no token needed. This matches CI, which installs
# with a single --index-url at this same devpi.
# ----------------------------------------------------------------------
[tool.uv]
index-url = "https://195.15.203.250.sslip.io/magogi/prod/+simple/"

# ----------------------------------------------------------------------
# Gate 1 — ruff (lint + format)
# ----------------------------------------------------------------------
[tool.ruff]
line-length = 100
target-version = "py{{ cookiecutter.python_version.replace('.', '') }}"
src = ["src", "tests"]

[tool.ruff.lint]
# Mirrors mgf-common's selection (see mgf-common's pyproject for the
# full rationale).
select = [
    "E", "W", "F", "I", "N", "UP", "B", "A", "C4", "PIE", "SIM",
    "RET", "RUF", "PTH", "TCH", "DTZ", "ASYNC", "S",
]
ignore = [
    "E501",   # line length — handled by formatter
    "S101",   # asserts — covered by per-file-ignore for tests/
]

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101", "PLR2004"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
line-ending = "lf"

# ----------------------------------------------------------------------
# Gate 2 — mypy (strict type checking)
# ----------------------------------------------------------------------
[tool.mypy]
python_version = "{{ cookiecutter.python_version }}"
strict = true
mypy_path = "src"
packages = ["{{ cookiecutter.package_name }}"]

# ----------------------------------------------------------------------
# Gate 3 — pytest (filterwarnings=error per rule TS-04)
# ----------------------------------------------------------------------
[tool.pytest.ini_options]
minversion = "8.0"
testpaths = ["tests"]
addopts = ["-ra", "--strict-markers", "--strict-config"]
filterwarnings = [
    "error",
    # Allow mgf-common's own deprecation warnings during the
    # cycle — fail-on-error still works via -W (consumer choice).
    "default::mgf.common._warnings.MgfDeprecationWarning",
]

[tool.coverage.run]
source = ["src/{{ cookiecutter.package_name }}"]
branch = true

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "raise NotImplementedError",
    "if TYPE_CHECKING:",
    "if __name__ == .__main__.:",
]
fail_under = 80

# ----------------------------------------------------------------------
# Gate 4 — import-linter (layering)
# ----------------------------------------------------------------------
[tool.importlinter]
root_packages = ["{{ cookiecutter.package_name }}"]

[[tool.importlinter.contracts]]
name = "{{ cookiecutter.package_name }} core does not depend on higher layers"
type = "layers"
layers = [
    "{{ cookiecutter.package_name }}.cli",
    "{{ cookiecutter.package_name }}.core",
]
