mirror of
https://github.com/mesonbuild/meson.git
synced 2026-11-06 05:16:42 +00:00
options: cleanup argparse_prefixed_default
It is used even outside argparse, and it also does not need an isinstance check. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
1 parent
516edbf6f6
commit
aba5221e00
2 files changed
+4
-6
No files matched your search
@@ -158,7 +158,7 @@ class BuiltinAction(argparse.Action):
|
||||
kwargs['nargs'] = 1
|
||||
if help_suffix:
|
||||
help_suffix += ', '
|
||||
help_suffix += 'default: ' + str(options.argparse_prefixed_default(option, name=option_key))
|
||||
help_suffix += 'default: ' + str(options.prefixed_default(option, name=option_key))
|
||||
if isinstance(option, (options.EnumeratedUserOption, options.UserArrayOption)):
|
||||
kwargs['choices'] = option.choices
|
||||
|
||||
|
||||
@@ -646,13 +646,11 @@ def argparse_name_to_arg(name: str) -> str:
|
||||
return '--' + name.replace('_', '-')
|
||||
|
||||
|
||||
def argparse_prefixed_default(opt: AnyOptionType, name: OptionKey, prefix: str = '') -> ElementaryOptionValues:
|
||||
if isinstance(opt, (UserComboOption, UserIntegerOption, UserUmaskOption)):
|
||||
return T.cast('ElementaryOptionValues', opt.default)
|
||||
def prefixed_default(opt: AnyOptionType, name: OptionKey, prefix: str = '') -> ElementaryOptionValues:
|
||||
try:
|
||||
return BUILTIN_DIR_NOPREFIX_OPTIONS[name][prefix]
|
||||
except KeyError:
|
||||
return T.cast('ElementaryOptionValues', opt.default)
|
||||
return opt.default
|
||||
|
||||
|
||||
# Update `docs/markdown/Builtin-options.md` after changing the options below
|
||||
@@ -942,7 +940,7 @@ class OptionStore:
|
||||
# Create a copy of the object, as we're going to mutate it
|
||||
opt = copy.copy(opt)
|
||||
assert key.subproject is None
|
||||
new_value = argparse_prefixed_default(opt, key, default_prefix())
|
||||
new_value = prefixed_default(opt, key, default_prefix())
|
||||
opt.set_value(new_value)
|
||||
|
||||
modulename = key.get_module_prefix()
|
||||
|
||||
Reference in new issue
Block a user