Skip to content

Commit be7ebc7

Browse files
committed
fix missing errors on __post_init__
1 parent 3424394 commit be7ebc7

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

datamodel/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ def __post_init__(self) -> None:
165165
Fill fields with function-factory or calling validations
166166
"""
167167
# checking if an attribute is already a dataclass:
168+
errors = {}
168169
for _, f in self.__columns__.items():
169170
value = getattr(self, f.name)
170171
name = f.name
171172
self._calculate_value(name, value, f)
172-
errors = {}
173173
try:
174174
value = getattr(self, f.name)
175175
error = self._validation(name, value, f)
@@ -181,7 +181,7 @@ def __post_init__(self) -> None:
181181
if self.Meta.strict is True:
182182
raise ValidationError(
183183
f"""{self.modelName}: There are errors in your Model. Hint: please check the "payload" attribute in the exception.""",
184-
payload = errors
184+
payload=errors
185185
)
186186
self.__errors__ = errors
187187
object.__setattr__(self, "__valid__", False)

datamodel/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def to_dict(self):
5252
return self.remove_nulls(asdict(self, dict_factory=dict))
5353
return asdict(self)
5454

55-
5655
def json(self, **kwargs):
5756
encoder = self.__encoder__(**kwargs)
5857
return encoder(asdict(self))

datamodel/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
__title__ = 'python-datamodel'
44
__description__ = ('simple library based on python +3.8 to use Dataclass-syntax'
55
'for interacting with Data')
6-
__version__ = '0.3.11'
6+
__version__ = '0.3.12'
77
__author__ = 'Jesus Lara'
88
__author_email__ = '[email protected]'
99
__license__ = 'BSD'

0 commit comments

Comments
 (0)