"""Test that package version is consistent across configuration files."""

import tomllib
from pathlib import Path

import deepagents


def test_version_matches_pyproject() -> None:
    """Verify that __version__ in __init__.py matches version in pyproject.toml."""
    # Get the version from the package __init__.py
    init_version = deepagents.__version__

    # Read the version from pyproject.toml
    pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
    with pyproject_path.open("rb") as f:
        pyproject_data = tomllib.load(f)

    pyproject_version = pyproject_data["project"]["version"]

    # Assert they match
    assert init_version == pyproject_version, (
        f"Version mismatch: __init__.py has '{init_version}' but "
        f"pyproject.toml has '{pyproject_version}'. "
        "Please update deepagents/__init__.py to match pyproject.toml."
    )
