1
0

config: add sanity check for duplicate config keys

This commit is contained in:
SomberNight
2023-09-08 15:09:17 +00:00
parent 8c9fec4ab8
commit 87f5df1e8b

View File

@@ -68,6 +68,7 @@ class ConfigVar(property):
self._default = default
self._type = type_
property.__init__(self, self._get_config_value, self._set_config_value)
assert key not in _config_var_from_key, f"duplicate config key str: {key!r}"
_config_var_from_key[key] = self
def _get_config_value(self, config: 'SimpleConfig'):
@@ -105,8 +106,8 @@ class ConfigVar(property):
return f"<ConfigVar key={self._key!r}>"
def __deepcopy__(self, memo):
cv = ConfigVar(self._key, default=self._default, type_=self._type)
return cv
# We can be considered ~stateless. State is stored in the config, which is external.
return self
class ConfigVarWithConfig: