Skip to content
Snippets Groups Projects
Verified Commit e361fde1 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

rename `required_fields` to `fields`

parent 8fec4116
No related branches found
No related tags found
No related merge requests found
......@@ -223,10 +223,10 @@ def _check_extra_class_fields(
def _check_class_fields(
obj: Dict[str, Any],
name: str,
required_fields: Dict[str, bool],
fields: Dict[str, bool],
sub_path: List[str] = None
):
for f, is_optional in required_fields.items():
for f, is_optional in fields.items():
if not is_optional and not f in obj.keys():
full_path = '.'.join(sub_path + [f]) if sub_path is not None else f
panic(
......@@ -234,7 +234,7 @@ def _check_class_fields(
f"missing required field '{full_path}' in {name}",
)
_check_extra_class_fields(obj, name, required_fields, sub_path=sub_path)
_check_extra_class_fields(obj, name, fields, sub_path=sub_path)
def check(graphs: Any):
......@@ -246,8 +246,8 @@ def check(graphs: Any):
f"input is not a list, found {type(graphs).__name__}",
)
required_graph_fields = __get_class_fields(Graph)
required_point_fields = __get_class_fields(Point)
graph_fields = __get_class_fields(Graph)
point_fields = __get_class_fields(Point)
for i, g in enumerate(graphs):
debug(f"checking graph {i}")
......@@ -259,11 +259,11 @@ def check(graphs: Any):
name = g.get('name', i)
_check_class_fields(g, f"graph {name}", required_graph_fields)
_check_class_fields(g, f"graph {name}", graph_fields)
for j, p in enumerate(g["points"]):
_check_class_fields(
p, f"graph {name}", required_point_fields, sub_path=["points", str(j)]
p, f"graph {name}", point_fields, sub_path=["points", str(j)]
)
# TODO: check style
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment