fix: better detection of multi variable in default attribute
This commit is contained in:
parent
0bc1e24d38
commit
c494a4662f
1 changed files with 9 additions and 7 deletions
|
|
@ -507,12 +507,15 @@ class _VariableCalculation(Calculation):
|
||||||
if self.allow_none:
|
if self.allow_none:
|
||||||
params["allow_none"] = True
|
params["allow_none"] = True
|
||||||
if needs_multi is None:
|
if needs_multi is None:
|
||||||
if self.attribute_name != "default":
|
if self.attribute_name == "default":
|
||||||
needs_multi = True
|
# variable is a multi or a submulti follower
|
||||||
|
attended = "submulti" if self.path in objectspace.followers else True
|
||||||
|
needs_multi = objectspace.multis.get(self.path) == attended
|
||||||
else:
|
else:
|
||||||
needs_multi = self.path in objectspace.multis
|
needs_multi = True
|
||||||
calc_variable_is_multi = variable.path in objectspace.multis
|
calc_variable_is_multi = variable.path in objectspace.multis
|
||||||
if not calc_variable_is_multi:
|
if not calc_variable_is_multi:
|
||||||
|
# a variable in a dynamic family can be multiple
|
||||||
if variable.path in objectspace.paths._dynamics and (
|
if variable.path in objectspace.paths._dynamics and (
|
||||||
identifier is None or identifier[-1] is None
|
identifier is None or identifier[-1] is None
|
||||||
):
|
):
|
||||||
|
|
@ -538,10 +541,9 @@ class _VariableCalculation(Calculation):
|
||||||
elif self.inside_list:
|
elif self.inside_list:
|
||||||
msg = _('the variable "{0}" has an invalid attribute "{1}", it\'s a list').format(self.path, self.attribute_name)
|
msg = _('the variable "{0}" has an invalid attribute "{1}", it\'s a list').format(self.path, self.attribute_name)
|
||||||
raise DictConsistencyError(msg, 23, self.xmlfiles)
|
raise DictConsistencyError(msg, 23, self.xmlfiles)
|
||||||
elif calc_variable_is_multi:
|
elif calc_variable_is_multi and self.path in objectspace.followers:
|
||||||
if (
|
if (
|
||||||
variable.multi
|
variable.path.rsplit(".", 1)[0] != self.path.rsplit(".", 1)[0]
|
||||||
or variable.path.rsplit(".", 1)[0] != self.path.rsplit(".", 1)[0]
|
|
||||||
):
|
):
|
||||||
if is_variable_calculation:
|
if is_variable_calculation:
|
||||||
# it's not a follower or not in same leadership
|
# it's not a follower or not in same leadership
|
||||||
|
|
@ -576,7 +578,7 @@ class VariableCalculation(_VariableCalculation):
|
||||||
or (objectspace.force_optional and self.attribute_name == "default")
|
or (objectspace.force_optional and self.attribute_name == "default")
|
||||||
):
|
):
|
||||||
raise VariableCalculationDependencyError()
|
raise VariableCalculationDependencyError()
|
||||||
if self.attribute_name == "default":
|
if variable and self.attribute_name == "default":
|
||||||
local_variable = objectspace.paths[self.path]
|
local_variable = objectspace.paths[self.path]
|
||||||
if CONVERT_OPTION.get(local_variable.type, {}).get("func", str) != CONVERT_OPTION.get(variable.type, {}).get("func", str):
|
if CONVERT_OPTION.get(local_variable.type, {}).get("func", str) != CONVERT_OPTION.get(variable.type, {}).get("func", str):
|
||||||
msg = _('variable "{0}" has a default value calculated with "{1}" which has incompatible type').format(self.path, variable.path)
|
msg = _('variable "{0}" has a default value calculated with "{1}" which has incompatible type').format(self.path, variable.path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue