automated terminal push

This commit is contained in:
lenape
2025-06-27 16:06:02 +00:00
parent 511dd3b36b
commit 6a954eb013
4221 changed files with 2916190 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
"""Useful internal functions."""
from typing import Any, Callable, NoReturn, Type, TypeVar
from ._compat import TypeAlias
from .errors import StructureHandlerNotFoundError
T = TypeVar("T")
Predicate: TypeAlias = Callable[[Any], bool]
"""A predicate function determines if a type can be handled."""
def identity(obj: T) -> T:
"""The identity function."""
return obj
def raise_error(_, cl: Type) -> NoReturn:
"""At the bottom of the condition stack, we explode if we can't handle it."""
msg = f"Unsupported type: {cl!r}. Register a structure hook for it."
raise StructureHandlerNotFoundError(msg, type_=cl)