"""
Python-version compatibility shims.

Centralises backports so a single class identity is shared across the
package — two independent ``class StrEnum(str, Enum)`` blocks would
be distinct types under ``isinstance``, even though they compute the
same values, and that breaks structural assumptions about enum
families on the 3.10 lane.
"""

from __future__ import annotations

import sys

if sys.version_info >= (3, 11):
    from enum import StrEnum
else:
    from enum import Enum

    class StrEnum(str, Enum):
        """Backport of ``enum.StrEnum`` for Python 3.10."""

        # Match stdlib 3.11+ ``enum.StrEnum``: ``str(member)`` returns
        # the value, not ``ClassName.MEMBER``. Plain ``class X(str,
        # Enum)`` inherits ``Enum.__str__`` which prints the qualified
        # name and breaks call sites interpolating the member into a
        # string (logger format args, wire payloads, test comparisons).
        __str__ = str.__str__

        @staticmethod
        def _generate_next_value_(name: str, *_: object) -> str:
            return name.lower()


__all__ = ["StrEnum"]
