]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
utils: modelling: error message when both transformation function and default value...
authorVasek Sraier <git@vakabus.cz>
Tue, 21 Sep 2021 14:12:06 +0000 (16:12 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 8 Apr 2022 14:17:53 +0000 (16:17 +0200)
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.

manager/knot_resolver_manager/utils/modelling.py

index f1b93dbd29e7c93e2e844d2bea5e1ff362836528..a8940fd3ffdcac0006f71633a15bdd2ba39be4dd 100644 (file)
@@ -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