From 53e11488d9ce01b14c2b280d66c3efeda1c60abc Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 28 Aug 2024 10:34:09 -0700 Subject: [PATCH] options: use a TypedDict for kwargs to ArgumentParser.add_argument This cleans up some more typing issues. --- mesonbuild/options.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mesonbuild/options.py b/mesonbuild/options.py index e3fe98ef99f2..9f65cc6b7bc9 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -27,6 +27,16 @@ ) from . import mlog +if T.TYPE_CHECKING: + from typing_extensions import TypedDict + + class ArgparseKWs(TypedDict, total=False): + + action: str + dest: str + default: str + choices: T.List + DEFAULT_YIELDING = False # Can't bind this near the class method it seems, sadly. @@ -567,7 +577,7 @@ def prefixed_default(self, name: 'OptionKey', prefix: str = '') -> T.Any: return self.default def add_to_argparse(self, name: str, parser: argparse.ArgumentParser, help_suffix: str) -> None: - kwargs = OrderedDict() + kwargs: ArgparseKWs = {} c = self._argparse_choices() b = self._argparse_action()