Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dargs/dargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ def _check_value(self, value: Any, path=None):
def _check_strict(self, value: dict, path=None):
allowed_keys = self.flatten_sub(value, path).keys()
# curpath = [*path, self.name]
if not len(allowed_keys):
# no allowed keys defined, allow any keys
return
for name in value.keys():
if name not in allowed_keys:
raise ArgumentKeyError(path,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_name_type(self):
# check any keywords
ca = Argument("kwargs", dict)
anydict = {"this": 1, "that": 2, "any": 3}
ca.check({"kwargs": anydict})
ca.check({"kwargs": anydict}, strict=True)
ca.check_value(anydict)

def test_sub_fields(self):
Expand Down