@constraint
def unique_names(self):
names: Set[str] = set()
for base in self.extending_sections:
for quantity in base.quantities + base.sub_sections:
for alias in quantity.aliases:
names.add(alias)
names.add(quantity.name)
for def_list in [self.quantities, self.sub_sections]:
for definition in def_list:
assert definition.name not in names, 'All names in a section must be unique. ' \
'Name %s of %s in %s already exists in %s.' % (definition.name, definition, definition.m_parent, self)
names.add(definition.name)
for alias in definition.aliases:
assert alias not in names, 'All names (incl. aliases) in a section must be unique. ' \
'Alias %s of %s in %s already exists in %s.' % (alias, definition, definition.m_parent, self)
names.add(alias)