Skip to content

Commit e55393c

Browse files
better doc dict check error messages
1 parent 49fcc99 commit e55393c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

WDoc/utils/misc.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,15 @@ class DocDict(dict):
151151

152152
def __check_values__(self, key, value):
153153
if key not in self.allowed_keys:
154-
raise Exception(f"Cannot set key '{key}' in a DocDict")
154+
raise Exception(
155+
f"Cannot set key '{key}' in a DocDict. Allowed keys are "
156+
f"'{','.join(self.allowed_keys)}'"
157+
)
155158
if key in self.allowed_types and value is not None:
156-
assert isinstance(value, self.allowed_types[key])
159+
assert isinstance(value, self.allowed_types[key]), (
160+
f"Type of key {key} should be {self.allowed_types[key]},"
161+
f"not {type(value)}"
162+
)
157163

158164
def __init__(self, *args, **kwargs):
159165
for arg in args:

0 commit comments

Comments
 (0)