try:
for i, val in enumerate(obj):
res.append(self.map_object(inner_type, val, object_path=f"{object_path}[{i}]"))
+ if len(res) == 0:
+ raise DataValidationError("empty list is not allowed", object_path)
except DataValidationError as e:
errs.append(e)
except TypeError as e:
_TestStr(parse_yaml("v: false")) # bool
+def test_parsing_list_empty():
+ class ListSchema(ConfigSchema):
+ empty: List[Any]
+
+ with raises(DataValidationError):
+ ListSchema(parse_yaml("empty: []"))
+
+
@pytest.mark.parametrize("typ,val", [(_TestInt, 5), (_TestBool, False), (_TestStr, "test")])
def test_parsing_nested(typ: Type[ConfigSchema], val: Any):
class UpperSchema(ConfigSchema):