9
9
import functools
10
10
import typing
11
11
from 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
13
13
14
14
import jinja2
15
15
from typing_extensions import Type , dataclass_transform
18
18
Literal ,
19
19
SerdeError ,
20
20
SerdeSkip ,
21
+ T ,
21
22
UserError ,
22
23
find_generic_arg ,
23
24
get_args ,
@@ -367,7 +368,7 @@ def deserialize(cls, data, **opts):
367
368
raise NotImplementedError
368
369
369
370
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 :
371
372
"""
372
373
Deserialize from an object into an instance of the type specified as arg `c`.
373
374
`c` can be either primitive type, `List`, `Tuple`, `Dict` or `deserialize` class.
@@ -462,7 +463,7 @@ def deserializable_to_obj(cls):
462
463
raise SerdeError (e )
463
464
464
465
465
- def from_dict (cls , o , reuse_instances : bool = ...):
466
+ def from_dict (cls : Type [ T ] , o , reuse_instances : bool = ...) -> T :
466
467
"""
467
468
Deserialize dictionary into object.
468
469
@@ -485,7 +486,7 @@ def from_dict(cls, o, reuse_instances: bool = ...):
485
486
return from_obj (cls , o , named = True , reuse_instances = reuse_instances )
486
487
487
488
488
- def from_tuple (cls , o , reuse_instances : bool = ...):
489
+ def from_tuple (cls : Type [ T ] , o : Any , reuse_instances : bool = ...) -> T :
489
490
"""
490
491
Deserialize tuple into object.
491
492
0 commit comments