// Override the required set
if var.is_required():
self._requiredVars.add(key)
elif key in self._requiredVars:
self._requiredVars.remove(key)
self._attr[key] = var.types
@property
After Change
self._attr[key] = val
def extend(self, cls):
localVarSpace = getattr(cls, self.localAttrSpaceName)
// Extend the var space
for key, var in localVarSpace.items():
// Disable redeclaring a variable
if key in self._attr:
raise ValueError(
f"cannot redeclare a variable ({key!r})"
)
self._attr[key] = var
// Undefine the vars as indicated by the local var space
for key in localVarSpace.undefined:
self._check_var_is_declared(key)
self._attr[key].undefine()
// Define the vars as indicated by the local var space
for key, val in localVarSpace.definitions.items():
self._check_var_is_declared(key)
self._attr[key].define(val)
def _check_var_is_declared(self, key):
if key not in self._attr:
raise ValueError(
f"var {key!r} has not been declared"