feat: add default inference behavior for basic types #13

Closed
gremond wants to merge 10 commits from basic_types_inference into develop
Showing only changes of commit 955b293403 - Show all commits

View file

@ -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: