Skip to content

Commit

Permalink
More types
Browse files Browse the repository at this point in the history
  • Loading branch information
singiamtel committed Nov 21, 2024
1 parent 219850c commit c5f2c63
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions alibuild_helpers/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit c5f2c63

Please sign in to comment.