diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2025-01-29 15:04:00 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2025-02-12 10:35:35 -0800 |
commit | ea678ed82938ceac00682b2695b57193d36b71b4 (patch) | |
tree | 310678bc2e14bbc1ec075e4a12e105f3cb90d1a7 | |
parent | 5e7b1a9d1decdb8773656ce187bbdb3c39987689 (diff) | |
download | meson-ea678ed82938ceac00682b2695b57193d36b71b4.zip meson-ea678ed82938ceac00682b2695b57193d36b71b4.tar.gz meson-ea678ed82938ceac00682b2695b57193d36b71b4.tar.bz2 |
build: fix typing of `Target.get_option`
Which can return any of `ElementaryOptionValues`, but is currently typed
as if it only returns `str | int | bool`.
-rw-r--r-- | mesonbuild/build.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c72857d..82d97fd 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -49,6 +49,7 @@ if T.TYPE_CHECKING: from .mesonlib import ExecutableSerialisation, FileMode, FileOrString from .modules import ModuleState from .mparser import BaseNode + from .options import ElementaryOptionValues GeneratedTypes = T.Union['CustomTarget', 'CustomTargetIndex', 'GeneratedList'] LibTypes = T.Union['SharedLibrary', 'StaticLibrary', 'CustomTarget', 'CustomTargetIndex'] @@ -679,10 +680,8 @@ class Target(HoldableObject, metaclass=abc.ABCMeta): def get_options(self) -> coredata.OptionsView: return self.options - def get_option(self, key: 'OptionKey') -> T.Union[str, int, bool]: - # TODO: if it's possible to annotate get_option or validate_option_value - # in the future we might be able to remove the cast here - return T.cast('T.Union[str, int, bool]', self.options.get_value(key)) + def get_option(self, key: OptionKey) -> ElementaryOptionValues: + return self.options.get_value(key) @staticmethod def parse_overrides(kwargs: T.Dict[str, T.Any]) -> T.Dict[OptionKey, str]: |