From ae15ad4ec5bb61dfee0fdd36a52229b1f6fa4a59 Mon Sep 17 00:00:00 2001 From: andy <20099514@qq.com> Date: Wed, 25 Jun 2025 11:35:34 +0800 Subject: [PATCH] bug fix for python 3.11 YAML is depred --- lightflow/config.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lightflow/config.py b/lightflow/config.py index bdecd2f..8779f83 100644 --- a/lightflow/config.py +++ b/lightflow/config.py @@ -164,7 +164,12 @@ def dag_polling_time(self): def set_to_default(self): """ Overwrite the configuration with the default configuration. """ - self._config = yaml.safe_load(self.default()) + # yaml = YAML(type='safe', pure=True) + y = yaml.YAML(typ='safe', pure=True) + # yaml.default_flow_style = False + # yaml.indent(mapping=2, sequence=4, offset=2) + # yaml.preserve_quotes = True + self._config = y.load(self.default()) def _update_from_file(self, filename): """ Helper method to update an existing configuration with the values from a file. @@ -178,7 +183,8 @@ def _update_from_file(self, filename): if os.path.exists(filename): try: with open(filename, 'r') as config_file: - yaml_dict = yaml.safe_load(config_file.read()) + y = yaml.YAML(typ='safe', pure=True) + yaml_dict = y.load(config_file.read()) if yaml_dict is not None: self._update_dict(self._config, yaml_dict) except IsADirectoryError: