]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Remove kwargs argument from run() and spawn()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 16 Jul 2023 17:57:54 +0000 (19:57 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 17 Jul 2023 11:05:52 +0000 (13:05 +0200)
Let's prefer listing arguments explicitly so that mypy can catch
the wrong ones easily.

mkosi/run.py

index dc2e3c7569f3a1594c3e5cf43542636c387f5df9..d9654e3aaeccbf3c651e7744c13c337e0cbe35e7 100644 (file)
@@ -224,9 +224,9 @@ def run(
     stdout: _FILE = None,
     stderr: _FILE = None,
     input: Optional[str] = None,
+    text: bool = True,
     env: Mapping[str, PathString] = {},
     log: bool = True,
-    **kwargs: Any,
 ) -> CompletedProcess:
     if ARG_DEBUG.get():
         logging.info(f"+ {' '.join(str(s) for s in cmdline)}")
@@ -254,15 +254,17 @@ def run(
         stdin = subprocess.DEVNULL
 
     try:
-        return subprocess.run(cmdline,
-                              check=check,
-                              stdin=stdin,
-                              stdout=stdout,
-                              stderr=stderr,
-                              input=input,
-                              env=env,
-                              **kwargs,
-                              preexec_fn=foreground)
+        return subprocess.run(
+            cmdline,
+            check=check,
+            stdin=stdin,
+            stdout=stdout,
+            stderr=stderr,
+            input=input,
+            text=True,
+            env=env,
+            preexec_fn=foreground,
+        )
     except FileNotFoundError:
         die(f"{cmdline[0]} not found in PATH.")
     except subprocess.CalledProcessError as e:
@@ -275,9 +277,10 @@ def run(
 
 def spawn(
     cmdline: Sequence[PathString],
+    stdin: _FILE = None,
     stdout: _FILE = None,
     stderr: _FILE = None,
-    **kwargs: Any,
+    text: bool = True,
 ) -> Popen:
     if ARG_DEBUG.get():
         logging.info(f"+ {' '.join(str(s) for s in cmdline)}")
@@ -289,7 +292,14 @@ def spawn(
         stdout = sys.stderr
 
     try:
-        return subprocess.Popen(cmdline, stdout=stdout, stderr=stderr, **kwargs, preexec_fn=foreground)
+        return subprocess.Popen(
+            cmdline,
+            stdin=stdin,
+            stdout=stdout,
+            stderr=stderr,
+            text=text,
+            preexec_fn=foreground,
+        )
     except FileNotFoundError:
         die(f"{cmdline[0]} not found in PATH.")
     except subprocess.CalledProcessError as e: