feat: default type inference
This commit is contained in:
parent
035fd7bd7e
commit
955b293403
1 changed files with 14 additions and 4 deletions
|
@ -74,8 +74,18 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
if multi is False and variable.type is None:
|
||||
if type(variable.default) in basic_types:
|
||||
variable.type = basic_types[type(variable.default)]
|
||||
else:
|
||||
elif isinstance(variable.default, list):
|
||||
#if variable.name == "varname23":
|
||||
# print("IIIIIIIIIIIIIIIIIIIIIIIIIIIII")
|
||||
# print(variable.multi)
|
||||
if variable.multi is None or variable.multi is False:
|
||||
variable.multi = True
|
||||
if variable.type is None:
|
||||
variable.type = basic_types[type(variable.default[0])]
|
||||
#if variable.name == "varname23":
|
||||
# print(variable.multi)
|
||||
# print(variable.type)
|
||||
else:
|
||||
variable.type = "string"
|
||||
|
||||
# a boolean must have value, the default value is "True"
|
||||
|
@ -89,9 +99,9 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
pass
|
||||
# variable.default = variable.default.to_function(self.functions)
|
||||
elif isinstance(variable.default, list):
|
||||
if not multi:
|
||||
if not multi and variable.version == "1.0":
|
||||
raise Exception(
|
||||
f'The variable "{variable.path}" with a list has default value must have "multi" attribute'
|
||||
f'The variable "{variable.path}" with a list as default value must have "multi" attribute'
|
||||
)
|
||||
if variable.path in self.objectspace.followers:
|
||||
if multi != "submulti" and len(variable.default) != 1:
|
||||
|
|
Loading…
Reference in a new issue