from collections.abc import Callable
from typing import Any, Generic, TypeVar

from google.protobuf.descriptor import EnumDescriptor, FieldDescriptor

_T = TypeVar("_T")

def TruncateToFourByteFloat(original: float) -> float: ...
def ToShortestFloat(original: float) -> float: ...
def GetTypeChecker(
    field: FieldDescriptor,
) -> TypeChecker[Any] | IntValueChecker | EnumValueChecker | UnicodeValueChecker | DoubleValueChecker | BoolValueChecker: ...

class TypeChecker(Generic[_T]):
    def __init__(self, *acceptable_types: _T): ...
    def CheckValue(self, proposed_value: _T) -> _T: ...

class TypeCheckerWithDefault(TypeChecker[_T]):
    def __init__(self, default_value: _T, *acceptable_types: _T): ...
    def DefaultValue(self) -> _T: ...

class BoolValueChecker:
    def CheckValue(self, proposed_value: bool) -> bool: ...
    def DefaultValue(self) -> bool: ...

class IntValueChecker:
    def CheckValue(self, proposed_value: int) -> int: ...
    def DefaultValue(self) -> int: ...

class EnumValueChecker:
    def __init__(self, enum_type: EnumDescriptor) -> None: ...
    def CheckValue(self, proposed_value: int) -> int: ...
    def DefaultValue(self) -> int: ...

class UnicodeValueChecker:
    def CheckValue(self, proposed_value: str) -> str: ...
    def DefaultValue(self) -> str: ...

class Int32ValueChecker(IntValueChecker): ...
class Uint32ValueChecker(IntValueChecker): ...
class Int64ValueChecker(IntValueChecker): ...
class Uint64ValueChecker(IntValueChecker): ...

class DoubleValueChecker:
    def CheckValue(self, proposed_value: float) -> float: ...
    def DefaultValue(self) -> float: ...

class FloatValueChecker(DoubleValueChecker):
    def CheckValue(self, proposed_value: float) -> float: ...

TYPE_TO_BYTE_SIZE_FN: dict[int, Callable[..., int]]
TYPE_TO_ENCODER: dict[int, Callable[..., Any]]
TYPE_TO_SIZER: dict[int, Callable[..., Any]]
TYPE_TO_DECODER: dict[int, Callable[..., Any]]
FIELD_TYPE_TO_WIRE_TYPE: dict[int, int]
