From c5f2c63f18d1432215094388c37f56e42120389d Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 21 Nov 2024 09:44:39 +0100 Subject: [PATCH] More types --- alibuild_helpers/cmd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/alibuild_helpers/cmd.py b/alibuild_helpers/cmd.py index 4f411f4a..3687510c 100644 --- a/alibuild_helpers/cmd.py +++ b/alibuild_helpers/cmd.py @@ -8,7 +8,7 @@ from alibuild_helpers.log import debug, warning, dieOnError -def decode_with_fallback(data): +def decode_with_fallback(data : bytes | str) -> str: """Try to decode DATA as utf-8; if that doesn't work, fall back to latin-1. This combination should cover every possible byte string, as latin-1 covers @@ -23,7 +23,7 @@ def decode_with_fallback(data): return str(data) -def getoutput(command, timeout=None): +def getoutput(command:str, timeout=None) -> str: """Run command, check it succeeded, and return its stdout as a string.""" proc = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=PIPE) try: @@ -37,7 +37,7 @@ def getoutput(command, timeout=None): return decode_with_fallback(stdout) -def getstatusoutput(command, timeout=None): +def getstatusoutput(command:str, timeout: int | None = None) -> tuple[int, str]: """Run command and return its return code and output (stdout and stderr).""" proc = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=STDOUT) try: