From eb561f5f528ddb8fa30c8ed5088462bd6e1b38a8 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 29 Jul 2024 12:04:31 +0200 Subject: [PATCH] allow 'variable' in dynamic family in 1.1 --- src/rougail/convert.py | 6 +++--- src/rougail/update.py | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/rougail/convert.py b/src/rougail/convert.py index 152bccb8c..1dbc342ca 100644 --- a/src/rougail/convert.py +++ b/src/rougail/convert.py @@ -480,7 +480,7 @@ class ParserVariable: return family_obj = {} subfamily_obj = {} - force_to_attrs = list(self.list_attributes(obj)) + force_to_attrs = list(self.list_attributes(obj, version)) for key, value in obj.items(): if key in force_to_attrs: if key.startswith("_"): @@ -558,6 +558,7 @@ class ParserVariable: def list_attributes( self, obj: Dict[str, Any], + version: str, ) -> Iterator[str]: """List attributes""" force_to_variable = [] @@ -580,8 +581,7 @@ class ParserVariable: ): # it's a dict, so a new variables! continue - # FIXME should be remove with 1.0 format - if key == "variable" and obj.get("type") != "dynamic": + if version == '1.0' and key == "variable" and obj.get("type") != "dynamic" and obj.get("_type") != "dynamic": continue if key in self.family_attrs: yield key diff --git a/src/rougail/update.py b/src/rougail/update.py index 44ca4eb35..fa0546c4e 100644 --- a/src/rougail/update.py +++ b/src/rougail/update.py @@ -35,9 +35,8 @@ except ModuleNotFoundError as err: # from ast import parse as ast_parse from json import dumps -from pathlib import Path - from ruamel.yaml import YAML +from pathlib import Path from .config import RougailConfig from .error import UpgradeError