diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-02-26 12:47:48 -0800 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2025-02-27 23:33:39 +0200 |
| commit | d9f3f6c0b27476edc84ccddecb373af88fde1053 (patch) | |
| tree | 5d6790e0979d8478323743e90fd8d2205a9a70c5 | |
| parent | 9300c3af91373b129deaa0255a9eb2f1ab2b309e (diff) | |
| download | meson-d9f3f6c0b27476edc84ccddecb373af88fde1053.tar.gz | |
use ElementaryOptionValues instead of open coding... again
| -rw-r--r-- | mesonbuild/backend/backends.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/compilers.py | 2 | ||||
| -rw-r--r-- | mesonbuild/modules/__init__.py | 3 | ||||
| -rw-r--r-- | mesonbuild/options.py | 2 |
4 files changed, 6 insertions, 4 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index baf83e849..88b3357be 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -41,6 +41,7 @@ if T.TYPE_CHECKING: from ..interpreter import Interpreter, Test from ..linkers.linkers import StaticLinker from ..mesonlib import FileMode, FileOrString + from ..options import ElementaryOptionValues from typing_extensions import TypedDict, NotRequired @@ -2105,7 +2106,7 @@ class Backend: return target.subproject != '' raise MesonException(f'Internal error: invalid option type for "unity": {val}') - def get_target_option(self, target: build.BuildTarget, name: T.Union[str, OptionKey]) -> T.Union[str, int, bool, T.List[str]]: + def get_target_option(self, target: build.BuildTarget, name: T.Union[str, OptionKey]) -> ElementaryOptionValues: if isinstance(name, str): key = OptionKey(name, subproject=target.subproject) elif isinstance(name, OptionKey): diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index e4c7f7744..7e061ba47 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1419,7 +1419,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): env: Environment, target: T.Optional[BuildTarget], subproject: T.Optional[str] = None - ) -> T.Union[str, int, bool, T.List[str]]: + ) -> options.ElementaryOptionValues: if isinstance(key, str): key = self.form_compileropt_key(key) if target: diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index f9374cc1d..fefe41a44 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -20,6 +20,7 @@ if T.TYPE_CHECKING: from ..interpreterbase import TYPE_var, TYPE_kwargs from ..programs import OverrideProgram from ..dependencies import Dependency + from ..options import ElementaryOptionValues class ModuleState: """Object passed to all module methods. @@ -132,7 +133,7 @@ class ModuleState: self._interpreter.func_test(self.current_node, real_args, kwargs) def get_option(self, name: str, subproject: str = '', - machine: MachineChoice = MachineChoice.HOST) -> T.Union[T.List[str], str, int, bool]: + machine: MachineChoice = MachineChoice.HOST) -> ElementaryOptionValues: return self.environment.coredata.get_option(OptionKey(name, subproject, machine)) def is_user_defined_option(self, name: str, subproject: str = '', diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 2e847a643..4295f476b 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -288,7 +288,7 @@ class UserOption(T.Generic[_T], HoldableObject): def listify(self, value: T.Any) -> T.List[T.Any]: return [value] - def printable_value(self) -> T.Union[str, int, bool, T.List[T.Union[str, int, bool]]]: + def printable_value(self) -> ElementaryOptionValues: assert isinstance(self.value, (str, int, bool, list)) return self.value |
