File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 11""" Defines interface contracts."""
22import sys
3+ from typing import TypeVar
34
45
6+ T = TypeVar ("T" , bound = "SerializableToDict" )
7+
58class 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 ) :
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
1619 """
17- _options = options .copy ()
20+ _options : dict = options .copy ()
1821 _options .pop ("kind" )
1922 _ir = {}
2023 for key , value in _options .items ():
@@ -29,7 +32,7 @@ def _fromInitializationDict(cls, options):
2932 _ir [key ] = value
3033 return cls (** _ir )
3134
32- def _toInitializationDict (self ):
35+ def _toInitializationDict (self ) -> dict :
3336 """ Converts an object to a Python dictionary. Keys represent the object's
3437 constructor arguments.
3538 :return: Python dictionary representation of the object
Original file line number Diff line number Diff line change @@ -152,7 +152,6 @@ exclude = [
152152 " dbldatagen/html_utils.py" ,
153153 " dbldatagen/nrange.py" ,
154154 " dbldatagen/schema_parser.py" ,
155- " dbldatagen/serialization.py" ,
156155 " dbldatagen/text_generator_plugins.py" ,
157156 " dbldatagen/text_generators.py"
158157]
You can’t perform that action at this time.
0 commit comments