Skip to content

Commit c1a258b

Browse files
committed
make fromdict method generic
1 parent 1d84ecb commit c1a258b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dbldatagen/serialization.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
""" Defines interface contracts."""
22
import sys
3+
from typing import TypeVar
34

45

6+
T = TypeVar("T", bound="SerializableToDict")
7+
58
class SerializableToDict:
69
""" Serializable objects must implement a `_getConstructorOptions` method
710
which converts the object properties to a Python dictionary whose keys
811
are the named arguments to the class constructor.
912
"""
1013

1114
@classmethod
12-
def _fromInitializationDict(cls, options: dict) -> object:
15+
def _fromInitializationDict(cls: type[T], options: dict) -> T:
1316
""" Converts a Python dictionary to an object using the object's constructor.
1417
:param options: Python dictionary with class constructor options
1518
:return: An instance of the class

0 commit comments

Comments
 (0)