99import functools
1010import typing
1111from dataclasses import dataclass , is_dataclass
12- from typing import Any , Callable , Dict , Iterator , List , Optional , TypeVar
12+ from typing import Any , Callable , Dict , List , Optional , TypeVar
1313
1414import jinja2
1515from typing_extensions import Type , dataclass_transform
1818 Literal ,
1919 SerdeError ,
2020 SerdeSkip ,
21+ T ,
2122 UserError ,
2223 find_generic_arg ,
2324 get_args ,
@@ -367,7 +368,7 @@ def deserialize(cls, data, **opts):
367368 raise NotImplementedError
368369
369370
370- def from_obj (c : Type , o : Any , named : bool , reuse_instances : bool ):
371+ def from_obj (c : Type [ T ] , o : Any , named : bool , reuse_instances : bool ) -> T :
371372 """
372373 Deserialize from an object into an instance of the type specified as arg `c`.
373374 `c` can be either primitive type, `List`, `Tuple`, `Dict` or `deserialize` class.
@@ -462,7 +463,7 @@ def deserializable_to_obj(cls):
462463 raise SerdeError (e )
463464
464465
465- def from_dict (cls , o , reuse_instances : bool = ...):
466+ def from_dict (cls : Type [ T ] , o , reuse_instances : bool = ...) -> T :
466467 """
467468 Deserialize dictionary into object.
468469
@@ -485,7 +486,7 @@ def from_dict(cls, o, reuse_instances: bool = ...):
485486 return from_obj (cls , o , named = True , reuse_instances = reuse_instances )
486487
487488
488- def from_tuple (cls , o , reuse_instances : bool = ...):
489+ def from_tuple (cls : Type [ T ] , o : Any , reuse_instances : bool = ...) -> T :
489490 """
490491 Deserialize tuple into object.
491492
0 commit comments