Skip to content

Commit ba2e87f

Browse files
authored
Linting serialization module (#350)
* Linting serialization module
1 parent 202338b commit ba2e87f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

dbldatagen/serialization.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
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):
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

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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
]

0 commit comments

Comments
 (0)