python 3.9 backward compatibility

This commit is contained in:
gwen 2024-03-19 15:31:12 +01:00
parent fa80fa14b4
commit 15327d20aa

View file

@ -67,6 +67,7 @@ from .object_model import (
from .error import DictConsistencyError
property_types = Union[Literal[True], Calculation]
properties_types = Dict[str, property_types]
@ -232,6 +233,8 @@ class ParserVariable:
self.default_multi = {}
self.jinja = {}
self.rougailconfig = rougailconfig
self.convert_options = list(CONVERT_OPTION)
self.convert_options.extend(self.rougailconfig["custom_types"])
#
self.family = Family
self.dynamic = Dynamic
@ -247,11 +250,10 @@ class ParserVariable:
super().__init__()
def get_variable(self):
convert_options = list(CONVERT_OPTION)
convert_options.extend(self.rougailconfig["custom_types"])
class Variable(_Variable):
type: Literal[*convert_options] = convert_options[0]
#type: Literal[*convert_options] = convert_options[0]
type: str = self.convert_options[0]
return Variable
@ -269,7 +271,8 @@ class ParserVariable:
)
#
hint = get_type_hints(self.variable)
self.variable_types = hint["type"].__args__ # pylint: disable=W0201
self.variable_types = self.convert_options #hint["type"].__args__ # pylint: disable=W0201
#
hint = get_type_hints(self.choice)
self.choice_attrs = frozenset( # pylint: disable=W0201