python lsp

This commit is contained in:
Christoph Brandau
2025-07-16 17:14:09 +02:00
parent 9febcebddb
commit 99718eb856
194 changed files with 52506 additions and 116 deletions
+22
View File
@@ -0,0 +1,22 @@
"""Useful internal functions."""
from typing import Any, Callable, NoReturn, 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: Any) -> 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)