From e87e51aac08522cca738707f904c19cb63f17b28 Mon Sep 17 00:00:00 2001 From: "Tim D. Smith" Date: Mon, 2 Nov 2020 14:25:04 -0800 Subject: [PATCH] Fix signature for generic structure hooks A generic structure hook is expected to return a value of the type that it accepts as an argument. --- src/cattr/converters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cattr/converters.py b/src/cattr/converters.py index 2d444163..5d4a6e3e 100644 --- a/src/cattr/converters.py +++ b/src/cattr/converters.py @@ -169,7 +169,7 @@ def register_unstructure_hook_func( self._unstructure_func.register_func_list([(check_func, func)]) def register_structure_hook( - self, cl: Type[T], func: Callable[[Any, Type[V]], T] + self, cl: Type[T], func: Callable[[Any, Type[T]], T] ): """Register a primitive-to-class converter function for a type. @@ -188,7 +188,7 @@ def register_structure_hook( def register_structure_hook_func( self, check_func: Callable[[Type[T]], bool], - func: Callable[[Any, Type[V]], T], + func: Callable[[Any, Type[T]], T], ): """Register a class-to-primitive converter function for a class, using a function to check if it's a match.