From 15327d20aa2fb3e81daf78da9d60039ca10ccbb1 Mon Sep 17 00:00:00 2001 From: gwen Date: Tue, 19 Mar 2024 15:31:12 +0100 Subject: [PATCH] python 3.9 backward compatibility --- src/rougail/convert.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rougail/convert.py b/src/rougail/convert.py index 0eb59d965..f3de86d01 100644 --- a/src/rougail/convert.py +++ b/src/rougail/convert.py @@ -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