]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
mkosi: do not build a temporary dictionary for kwargs
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Oct 2022 08:27:19 +0000 (10:27 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Oct 2022 08:43:54 +0000 (10:43 +0200)
Let's use the usual method for passing mixed inherited and local keyword args.
We don't need to put the argument names in quotes so this looks nicer. Also,
if we were to make a mistake and pass the same kwargs in two places, previously
the local assignment would silently override the other value. But that seems
inverted because now the base class overwrites something specified by the daughter
class. Anyway, it's better to throw an error, which we now will do:

TypeError: argparse.ArgumentParser.__init__() got multiple values for keyword argument '…'

mkosi/__init__.py

index 4419975267f7cdd7ed8801df8d5bdb338a942eca..93005e82349f214d09ff953c4d6b04f1e131b74e 100644 (file)
@@ -4950,11 +4950,12 @@ class ArgumentParserMkosi(argparse.ArgumentParser):
         self._ini_file_key = ""  # multi line list processing
         self._ini_file_list_mode = False
 
-        # Add config files to be parsed
-        kwargs["fromfile_prefix_chars"] = ArgumentParserMkosi.fromfile_prefix_chars
-        kwargs["formatter_class"] = CustomHelpFormatter
-
-        super().__init__(*kargs, **kwargs)
+        super().__init__(*kargs,
+                         # Add config files to be parsed:
+                         fromfile_prefix_chars=ArgumentParserMkosi.fromfile_prefix_chars,
+                         formatter_class=CustomHelpFormatter,
+                         # Pass through the other options:
+                         **kwargs)
 
     @staticmethod
     def _camel_to_arg(camel: str) -> str: