From 7600856e0a1b1e058ef684928ac29a92218b1257 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 3 May 2023 10:20:15 -0400 Subject: [PATCH] UserArrayOption: Make listify_value() a static method --- mesonbuild/coredata.py | 8 ++++++-- mesonbuild/mcompile.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 975719e89..97261d67a 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -256,7 +256,8 @@ class UserArrayOption(UserOption[T.List[str]]): self.allow_dups = allow_dups self.set_value(value) - def listify(self, value: T.Union[str, T.List[str]]) -> T.List[str]: + @staticmethod + def listify_value(value: T.Union[str, T.List[str]], shlex_split_args: bool = False) -> T.List[str]: if isinstance(value, str): if value.startswith('['): try: @@ -266,7 +267,7 @@ class UserArrayOption(UserOption[T.List[str]]): elif value == '': newvalue = [] else: - if self.split_args: + if shlex_split_args: newvalue = split_args(value) else: newvalue = [v.strip() for v in value.split(',')] @@ -276,6 +277,9 @@ class UserArrayOption(UserOption[T.List[str]]): raise MesonException(f'"{value}" should be a string array, but it is not') return newvalue + def listify(self, value: T.Any) -> T.List[T.Any]: + return self.listify_value(value, self.split_args) + def validate_value(self, value: T.Union[str, T.List[str]]) -> T.List[str]: newvalue = self.listify(value) diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index 950b27ca9..b9bd71bd3 100644 --- a/mesonbuild/mcompile.py +++ b/mesonbuild/mcompile.py @@ -35,7 +35,7 @@ if T.TYPE_CHECKING: import argparse def array_arg(value: str) -> T.List[str]: - return UserArrayOption(None, value, allow_dups=True).value + return UserArrayOption.listify_value(value) def validate_builddir(builddir: Path) -> None: if not (builddir / 'meson-private' / 'coredata.dat').is_file():