"""Python-specific language configuration."""

from __future__ import annotations

from typing import TYPE_CHECKING

import attrs

from codeflash_core import LanguageConfiguration

if TYPE_CHECKING:
    from pathlib import Path


@attrs.frozen
class PythonConfiguration(LanguageConfiguration):
    """Configuration for a Python optimization session.

    Extends :class:`LanguageConfiguration` with Python-specific
    settings.  Replaces the scattered config that was previously
    split across ``OptimizationConfig``, ``PythonOptimizer``,
    and ``TestConfig``.

    Usage::

        cfg = PythonConfiguration(
            project_root=Path("/code/myproject"),
            tests_root=Path("/code/myproject/tests"),
            test_framework="pytest",
            pytest_cmd="pytest",
        )
    """

    pytest_cmd: str = "pytest"
    """Command to invoke pytest (e.g. ``"pytest"`` or ``"python -m pytest"``)."""

    module_root: Path | None = None
    """Root of the Python package under optimization.

    Defaults to *project_root* if not specified.  Used for
    import resolution and module name computation.
    """

    coverage_db: Path | None = None
    """Path to an existing coverage.py SQLite database.

    When provided, the optimizer uses coverage data to rank
    functions by test coverage rather than profiling alone.
    """

    no_gen_tests: bool = False
    """Skip AI-powered test generation."""

    no_pr: bool = False
    """Skip PR creation after successful optimizations."""

    git_remote: str = "origin"
    """Git remote name for PR creation."""
