Skip to content

Commit b950357

Browse files
committed
fix lint issues
1 parent d337a25 commit b950357

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

serializer/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
from pathlib import Path
1616

17-
from ._core import _Serializable as SerializableMixin
18-
from ._core import serializable
19-
from ._serializer import serializer
17+
from ._core import _Serializable as SerializableMixin # noqa: F401
18+
from ._core import serializable # noqa: F401
19+
from ._serializer import serializer # noqa: F401
2020

2121
__version__ = open(Path(__file__).parents[0] / 'VERSION').read()
2222

@@ -30,4 +30,4 @@
3030
+ Contact : {__maintainer__} <{__email__}>
3131
+ Status : {__status__}
3232
+------======================================-------+
33-
"""
33+
""" # noqa: W291

serializer/_core.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111

1212
class NotADataClassInstance(Exception):
13-
""" Raised when trying to serialize a class without the __dataclass_fields__ attribute """
13+
"""
14+
Raised when trying to serialize a
15+
class without the __dataclass_fields__ attribute
16+
"""
1417
pass
1518

1619

@@ -20,11 +23,13 @@ def to_dict(self):
2023
""" Class function allowing conversion of an object to a dictionary"""
2124
if hasattr(self, '__serialize__'):
2225
return self.__serialize__()
23-
raise NotSerializableInstance(f"Could not serialize {type(self)} object.")
26+
raise NotSerializableInstance(
27+
f"Could not serialize {type(self)} object."
28+
)
2429

2530
@abc.abstractmethod
2631
def __serialize__(self):
27-
raise NotImplemented("abstract method")
32+
raise NotImplementedError("abstract method")
2833

2934

3035
class _SerializableDataclassMixin(_Serializable):
@@ -36,7 +41,8 @@ def __serialize__(self):
3641
for name, field in self.__dataclass_fields__.items():
3742
result[name] = serializer(getattr(self, name), name, field)
3843
return result
39-
raise NotADataClassInstance(f"Could not infer dataclass fields from {type(self)} object.")
44+
raise NotADataClassInstance(
45+
f"Could not infer dataclass fields from {type(self)} object.")
4046

4147
@classmethod
4248
def mixin(cls, klass, *args, **kwargs):
@@ -47,7 +53,10 @@ def mixin(cls, klass, *args, **kwargs):
4753

4854

4955
def serializable(_cls=None, *args, **kwargs):
50-
""" Wrapper to transform class into serializable (Note: extends dataclass) """
56+
"""
57+
Wrapper to transform class into serializable
58+
(Note: extends dataclass)
59+
"""
5160

5261
def wrap(cls):
5362
return _SerializableDataclassMixin.mixin(klass=cls, *args, **kwargs)

serializer/_serializer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ def serializer(value: object, name: str = None, field: Field = None):
4646
return None
4747

4848
name = value.__name__ if hasattr(value, '__name__') else ""
49-
raise NotSerializableInstance(f"Object({name}, {type(value)}) could not be serialized !!")
49+
raise NotSerializableInstance(
50+
f"Object({name}, {type(value)}) could not be serialized !!"
51+
)

0 commit comments

Comments
 (0)