Skip to content

Commit c7d2f8a

Browse files
committed
fix unit tests & mypy
1 parent 47cee93 commit c7d2f8a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/pyaddict/schema/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _coerceValue(self, value: Any, to: Type[T]) -> ValidationResult[T]:
8989
)
9090

9191
# str -> dict
92-
if to in (dict, list) and isinstance(value, str): # type: ignore # (comparison-overlap)
92+
if to in (dict, list) and isinstance(value, str):
9393
return ValidationResult.ok(json.loads(value))
9494

9595
try:
@@ -143,10 +143,10 @@ def __init__(self) -> None:
143143
def validate(self, value: T) -> ValidationResult[T]:
144144
"""validate the value"""
145145
if not self._enum:
146-
return ValidationResult.ok(value)
146+
return ValidationResult.ok(value, self._nullable)
147147

148148
if self._nullable and value is None:
149-
return ValidationResult.ok(value, True) # type: ignore
149+
return ValidationResult.ok(value, True)
150150

151151
if value not in self._enum:
152152
return ValidationResult.err(
@@ -177,7 +177,7 @@ def length(self, value: Any) -> int:
177177
def validate(self, value: T) -> ValidationResult[T]:
178178
"""validate the value"""
179179
if self._nullable and value is None:
180-
return ValidationResult.ok(value, True) # type: ignore
180+
return ValidationResult.ok(value, True)
181181

182182
if self._min is not None:
183183
length = self.length(value)

src/pyaddict/schema/schema.py

+2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ def validate(self, value: Any) -> ValidationResult[JObject]:
225225
return result
226226
continue
227227

228+
print(value, key, value[key], schema)
228229
keyRes = schema.validate(value[key])
230+
print("keyRes", keyRes)
229231
if not keyRes:
230232
result.invalidate(ValidationError.inherit(keyRes.error, [key]))
231233
return result

0 commit comments

Comments
 (0)