11"""Cattrs validation."""
2- from typing import Any, Callable, List, TypeVar, Union, overload
2+ from typing import Any, Callable, List, Tuple, Type, TypeVar, Union, overload
33
44from attrs import NOTHING, frozen
55
3737class VAnnotation:
3838 """Use this with Annotated to get validation."""
3939
40- validators: tuple[Callable[[Any], Any]]
40+ validators: Tuple[Callable[[Any], Any]]
41+
42+ def __init__(self, *validators: Callable[[Any], Any]):
43+ self.__attrs_init__(validators)
4144
4245
4346def format_exception(exc: BaseException, type: Union[type, None]) -> str:
@@ -153,13 +156,13 @@ def transform_error(
153156
154157@overload
155158def ensure(
156- type: type[list [T]], *validators: Callable[[list [T]], Any], elems: type [E]
157- ) -> type[list [E]]:
159+ type: Type[List [T]], *validators: Callable[[List [T]], Any], elems: Type [E]
160+ ) -> Type[List [E]]:
158161 ...
159162
160163
161164@overload
162- def ensure(type: type [T], *validators: Callable[[T], Any]) -> type [T]:
165+ def ensure(type: Type [T], *validators: Callable[[T], Any]) -> Type [T]:
163166 ...
164167
165168
@@ -168,5 +171,5 @@ def ensure(type: Any, *validators: Any, elems: Any = NOTHING) -> Any:
168171 # These are lists.
169172 if not validators:
170173 return type[elems]
171- return Annotated[type, VAnnotation(validators)]
172- return Annotated[type, VAnnotation(validators)]
174+ return Annotated[type, VAnnotation(* validators)]
175+ return Annotated[type, VAnnotation(* validators)]
0 commit comments