Skip to content

Commit d7a3d47

Browse files
authored
fix: properly typehint deepcopy_kwargs (#905)
1 parent 9514381 commit d7a3d47

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

interactions/api/models/attrs_utils.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import wraps
2-
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, Type
2+
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, Type, overload
33

44
import attrs
55

@@ -66,7 +66,15 @@ def convert_dict(
6666
) -> Callable[[Dict[Any, Any]], Dict[_T, _P]]:
6767
"""A helper function to convert the keys and values of a dictionary with the specified converters"""
6868

69-
def deepcopy_kwargs(cls: Optional[Type[_T]] = None) -> Callable[[Any], _T]:
69+
@overload
70+
def deepcopy_kwargs() -> Callable[[_T], _T]:
71+
...
72+
73+
@overload
74+
def deepcopy_kwargs(cls: _T) -> _T:
75+
...
76+
77+
def deepcopy_kwargs(cls: Optional[_T] = None) -> Union[Callable[[_T], _T], _T]:
7078
"""
7179
A decorator to make the DictSerializerMixin deepcopy the kwargs before processing them.
7280
This can help avoid weird bugs with some objects, though will error out in others.

0 commit comments

Comments
 (0)