You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2022/08/21 04:39:21 UTC

[buildstream] 02/02: element.py, _frontend/widget.py: Use _yaml.roundtrip_dump_string()

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/fix-ruamel-deprecation-warnings
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit df7647463d1dcdac3f7518740c7d9a49ca992e84
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sun Aug 21 13:37:54 2022 +0900

    element.py, _frontend/widget.py: Use _yaml.roundtrip_dump_string()
    
    Instead of deprecated round_trip_dump() from ruamel.yaml.
    
    This will silence a lot of the remaining pesky deprecation warnings after
    running tests in tox.
---
 src/buildstream/_frontend/widget.py | 16 +++++-----------
 src/buildstream/element.py          |  4 ++--
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py
index 4cede5f47..746fcba94 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -22,11 +22,11 @@ from contextlib import ExitStack
 from mmap import mmap
 import re
 import textwrap
-from ruamel import yaml
 import click
 
 from .profile import Profile
 from ..types import _Scope
+from .. import _yaml
 from .. import __version__ as bst_version
 from .. import FileType
 from .._exceptions import BstError, ImplError
@@ -384,29 +384,23 @@ class LogLine(Widget):
                 line = p.fmt_subst(
                     line,
                     "config",
-                    yaml.round_trip_dump(element._Element__config, default_flow_style=False, allow_unicode=True),
+                    _yaml.roundtrip_dump_string(element._Element__config),
                 )
 
             # Variables
             if "%{vars" in format_:
                 variables = dict(element._Element__variables)
-                line = p.fmt_subst(
-                    line, "vars", yaml.round_trip_dump(variables, default_flow_style=False, allow_unicode=True)
-                )
+                line = p.fmt_subst(line, "vars", _yaml.roundtrip_dump_string(variables))
 
             # Environment
             if "%{env" in format_:
                 environment = element._Element__environment
-                line = p.fmt_subst(
-                    line, "env", yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True)
-                )
+                line = p.fmt_subst(line, "env", _yaml.roundtrip_dump_string(environment))
 
             # Public
             if "%{public" in format_:
                 environment = element._Element__public
-                line = p.fmt_subst(
-                    line, "public", yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True)
-                )
+                line = p.fmt_subst(line, "public", _yaml.roundtrip_dump_string(environment))
 
             # Workspaced
             if "%{workspaced" in format_:
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 9382c8c61..66bc9cf8c 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -77,7 +77,6 @@ import string
 from typing import cast, TYPE_CHECKING, Any, Dict, Iterator, Iterable, List, Optional, Set, Sequence
 
 from pyroaring import BitMap  # pylint: disable=no-name-in-module
-from ruamel import yaml
 
 from . import _yaml
 from ._variables import Variables
@@ -1654,7 +1653,8 @@ class Element(Plugin):
         assert not self._cached_success()
 
         # Print the environment at the beginning of the log file.
-        env_dump = yaml.round_trip_dump(self.get_environment(), default_flow_style=False, allow_unicode=True)
+        env_dump = _yaml.roundtrip_dump_string(self.get_environment())
+
         self.log("Build environment for element {}".format(self.name), detail=env_dump)
 
         context = self._get_context()