From: Vasek Sraier Date: Tue, 21 Sep 2021 14:12:06 +0000 (+0200) Subject: utils: modelling: error message when both transformation function and default value... X-Git-Tag: v6.0.0a1~125^2~2^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4590da2b68ffb83327de4661848de162b62138ed;p=thirdparty%2Fknot-resolver.git utils: modelling: error message when both transformation function and default value set at the same time After a discussion, we decided that this situation does not make any sense and we don't know, how the program should behave. Therefore, we just disallow it. --- diff --git a/manager/knot_resolver_manager/utils/modelling.py b/manager/knot_resolver_manager/utils/modelling.py index f1b93dbd2..a8940fd3f 100644 --- a/manager/knot_resolver_manager/utils/modelling.py +++ b/manager/knot_resolver_manager/utils/modelling.py @@ -190,6 +190,10 @@ class SchemaNode: if val is not ...: setattr(self, name, val) used_keys.add(name) + + if hasattr(self, f"_{name}"): + # check, that the schema makes sense + raise TypeError(f"{cls.__name__}.{name}: can't have both default value and transformation function at once. Use _PREVIOUS_SCHEMA...") return used_keys