diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index b8702d5e9e93..356e655b3cb8 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -857,10 +857,10 @@ def save(obj: CoreData, build_dir: str) -> str: def register_builtin_arguments(parser: argparse.ArgumentParser) -> None: for n, b in options.BUILTIN_OPTIONS.items(): - b.add_to_argparse(str(n), parser, '') + b.add_to_argparse(n, parser, '') for n, b in options.BUILTIN_OPTIONS_PER_MACHINE.items(): - b.add_to_argparse(str(n), parser, ' (just for host machine)') - b.add_to_argparse(str(n.as_build()), parser, ' (just for build machine)') + b.add_to_argparse(n, parser, ' (just for host machine)') + b.add_to_argparse(n.as_build(), parser, ' (just for build machine)') parser.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option", help='Set the value of an option, can be used several times to set multiple options.') diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 047480297443..ae923fec2f63 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -588,7 +588,7 @@ def prefixed_default(self, name: 'OptionKey', prefix: str = '') -> T.Any: pass return self.default - def add_to_argparse(self, name: str, parser: argparse.ArgumentParser, help_suffix: str) -> None: + def add_to_argparse(self, name: OptionKey, parser: argparse.ArgumentParser, help_suffix: str) -> None: kwargs: ArgparseKWs = {} c = self._argparse_choices() @@ -601,9 +601,9 @@ def add_to_argparse(self, name: str, parser: argparse.ArgumentParser, help_suffi if c and not b: kwargs['choices'] = c kwargs['default'] = argparse.SUPPRESS - kwargs['dest'] = name + kwargs['dest'] = str(name) - cmdline_name = self.argparse_name_to_arg(name) + cmdline_name = self.argparse_name_to_arg(str(name)) parser.add_argument(cmdline_name, help=h + help_suffix, **kwargs)