Skip to content

Commit

Permalink
build: fix typing of Target.get_option
Browse files Browse the repository at this point in the history
Which can return any of `ElementaryOptionValues`, but is currently typed
as if it only returns `str | int | bool`.
  • Loading branch information
dcbaker committed Feb 6, 2025
1 parent 8373296 commit 477c05b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
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']
Expand Down Expand Up @@ -679,10 +680,8 @@ def set_option_overrides(self, option_overrides: T.Dict[OptionKey, str]) -> None
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]:
Expand Down

0 comments on commit 477c05b

Please sign in to comment.