dotfiles/vscode/.vscode/extensions/ms-python.black-formatter-2024.2.0/bundled/libs/cattrs/fns.py
Errol Sancaktar ff17c17e23 vscode
2024-06-14 09:31:58 -06:00

18 lines
476 B
Python

"""Useful internal functions."""
from typing import NoReturn, Type, TypeVar
from .errors import StructureHandlerNotFoundError
T = TypeVar("T")
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)