Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ElementaryOptionValues with OptionValueType #14273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mesonbuild/coredata.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from .mesonlib import FileOrString
from .cmake.traceparser import CMakeCacheEntry
from .interpreterbase import SubProject
from .options import ElementaryOptionValues
from .options import OptionValueType
from .build import BuildTarget

class SharedCMDOptions(Protocol):
Expand Down Expand Up @@ -394,13 +394,13 @@ def init_backend_options(self, backend_name: str) -> None:
'Default project to execute in Visual Studio',
''))

def get_option(self, key: OptionKey) -> ElementaryOptionValues:
def get_option(self, key: OptionKey) -> OptionValueType:
return self.optstore.get_value_for(key.name, key.subproject)

def get_option_object_for_target(self, target: 'BuildTarget', key: T.Union[str, OptionKey]) -> options.AnyOptionType:
return self.get_option_for_subproject(key, target.subproject)

def get_option_for_target(self, target: 'BuildTarget', key: T.Union[str, OptionKey]) -> ElementaryOptionValues:
def get_option_for_target(self, target: 'BuildTarget', key: T.Union[str, OptionKey]) -> OptionValueType:
if isinstance(key, str):
assert ':' not in key
newkey = OptionKey(key, target.subproject)
Expand All @@ -417,7 +417,7 @@ def get_option_for_target(self, target: 'BuildTarget', key: T.Union[str, OptionK
return option_object.validate_value(override)
return value

def get_option_for_subproject(self, key: T.Union[str, OptionKey], subproject) -> ElementaryOptionValues:
def get_option_for_subproject(self, key: T.Union[str, OptionKey], subproject) -> OptionValueType:
if isinstance(key, str):
key = OptionKey(key, subproject=subproject)
if key.subproject != subproject:
Expand Down Expand Up @@ -909,7 +909,7 @@ class OptionsView(abc.Mapping):
# python 3.8 or typing_extensions
original_options: T.Union[KeyedOptionDictType, 'dict[OptionKey, options.AnyOptionType]']
subproject: T.Optional[str] = None
overrides: T.Optional[T.Mapping[OptionKey, ElementaryOptionValues]] = dataclasses.field(default_factory=dict)
overrides: T.Optional[T.Mapping[OptionKey, OptionValueType]] = dataclasses.field(default_factory=dict)

def __getitem__(self, key: OptionKey) -> options.UserOption:
# FIXME: This is fundamentally the same algorithm than interpreter.get_option_internal().
Expand Down Expand Up @@ -953,7 +953,7 @@ def get_value(self, key: T.Union[str, OptionKey]):
key = OptionKey(key)
return self[key].value

def set_value(self, key: T.Union[str, OptionKey], value: ElementaryOptionValues):
def set_value(self, key: T.Union[str, OptionKey], value: OptionValueType):
if isinstance(key, str):
key = OptionKey(key)
self.overrides[key] = value
Expand Down
6 changes: 3 additions & 3 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ def notfound_program(self, args: T.List[mesonlib.FileOrString]) -> ExternalProgr
# the host machine.
def find_program_impl(self, args: T.List[mesonlib.FileOrString],
for_machine: MachineChoice = MachineChoice.HOST,
default_options: T.Optional[T.Dict[OptionKey, options.ElementaryOptionValues]] = None,
default_options: T.Optional[T.Dict[OptionKey, options.OptionValueType]] = None,
required: bool = True, silent: bool = True,
wanted: T.Union[str, T.List[str]] = '',
search_dirs: T.Optional[T.List[str]] = None,
Expand Down Expand Up @@ -1671,7 +1671,7 @@ def find_program_impl(self, args: T.List[mesonlib.FileOrString],
return progobj

def program_lookup(self, args: T.List[mesonlib.FileOrString], for_machine: MachineChoice,
default_options: T.Optional[T.Dict[OptionKey, options.ElementaryOptionValues]],
default_options: T.Optional[T.Dict[OptionKey, options.OptionValueType]],
required: bool,
search_dirs: T.Optional[T.List[str]],
wanted: T.Union[str, T.List[str]],
Expand Down Expand Up @@ -1739,7 +1739,7 @@ def check_program_version(self, progobj: T.Union[ExternalProgram, build.Executab
return True

def find_program_fallback(self, fallback: str, args: T.List[mesonlib.FileOrString],
default_options: T.Dict[OptionKey, options.ElementaryOptionValues],
default_options: T.Dict[OptionKey, options.OptionValueType],
required: bool, extra_info: T.List[mlog.TV_Loggable]
) -> T.Optional[T.Union[ExternalProgram, build.Executable, OverrideProgram]]:
mlog.log('Fallback to subproject', mlog.bold(fallback), 'which provides program',
Expand Down
6 changes: 3 additions & 3 deletions mesonbuild/interpreter/kwargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class Summary(TypedDict):

class FindProgram(ExtractRequired, ExtractSearchDirs):

default_options: T.Dict[OptionKey, options.ElementaryOptionValues]
default_options: T.Dict[OptionKey, options.OptionValueType]
native: MachineChoice
version: T.List[str]

Expand Down Expand Up @@ -312,7 +312,7 @@ class ConfigureFile(TypedDict):

class Subproject(ExtractRequired):

default_options: T.Dict[OptionKey, options.ElementaryOptionValues]
default_options: T.Dict[OptionKey, options.OptionValueType]
version: T.List[str]


Expand Down Expand Up @@ -346,7 +346,7 @@ class _BaseBuildTarget(TypedDict):
name_suffix: T.Optional[str]
native: MachineChoice
objects: T.List[build.ObjectTypes]
override_options: T.Dict[OptionKey, options.ElementaryOptionValues]
override_options: T.Dict[OptionKey, options.OptionValueType]
depend_files: NotRequired[T.List[File]]
resources: T.List[str]

Expand Down
4 changes: 2 additions & 2 deletions mesonbuild/interpreter/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from ..build import ObjectTypes
from ..interpreterbase import TYPE_var
from ..options import ElementaryOptionValues
from ..options import OptionValueType
from ..mesonlib import EnvInitValueType

_FullEnvInitValueType = T.Union[EnvironmentVariables, T.List[str], T.List[T.List[str]], EnvInitValueType, str, None]
Expand Down Expand Up @@ -293,7 +293,7 @@ def _env_convertor(value: _FullEnvInitValueType) -> EnvironmentVariables:
)


OVERRIDE_OPTIONS_KW: KwargInfo[T.Union[str, T.Dict[str, ElementaryOptionValues], T.List[str]]] = KwargInfo(
OVERRIDE_OPTIONS_KW: KwargInfo[T.Union[str, T.Dict[str, OptionValueType], T.List[str]]] = KwargInfo(
'override_options',
(str, ContainerTypeInfo(list, str), ContainerTypeInfo(dict, (str, int, bool, list))),
default={},
Expand Down
1 change: 0 additions & 1 deletion mesonbuild/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
'UserBooleanOption', 'UserComboOption', 'UserFeatureOption',
'UserIntegerOption', 'UserStdOption', 'UserStringArrayOption',
'UserStringOption', 'UserUmaskOption']
ElementaryOptionValues: TypeAlias = T.Union[str, int, bool, T.List[str]]

class ArgparseKWs(TypedDict, total=False):

Expand Down
Loading