Skip to content

Commit 48d3a8a

Browse files
committed
Fixed Python 3.7- compatibility with TypedDict
1 parent 1b07848 commit 48d3a8a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

udsoncan/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919
import binascii
2020
import functools
2121
import time
22+
import sys
2223

23-
from typing import Callable, Optional, Union, Dict, List, TypedDict, Any, cast, Type
24+
from typing import Callable, Optional, Union, Dict, List, Any, cast, Type
25+
26+
if sys.version_info < (3, 8):
27+
class TypedDict:
28+
pass
29+
else:
30+
from typing import TypedDict
2431

2532

2633
class SessionTiming(TypedDict):
@@ -153,8 +160,7 @@ def validate_config(self) -> None:
153160
# then suppresses them or not depending on the client configuration.
154161
# if func1 and func2 are decorated and func2 calls func1, it should be done this way : self.func1._func_no_error_management(self, ...)
155162

156-
@staticmethod
157-
def standard_error_management(func: Callable):
163+
def standard_error_management(func: Callable): # type: ignore
158164
@functools.wraps(func)
159165
def decorated(self: "Client", *args, **kwargs):
160166
try:

udsoncan/typing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
from udsoncan.common.DidCodec import DidCodec
2-
from typing import TypedDict, Dict, Optional, Any, Callable, Union, Type
2+
from typing import Dict, Optional, Any, Callable, Union, Type
3+
import sys
4+
5+
if sys.version_info < (3, 8):
6+
class TypedDict:
7+
def __init_subclass__(cls, *args, **kwargs):
8+
pass
9+
else:
10+
from typing import TypedDict
311

412
SecurityAlgoType = Callable[[int, bytes, Any], bytes]
513

0 commit comments

Comments
 (0)