Skip to content

Commit

Permalink
More types
Browse files Browse the repository at this point in the history
  • Loading branch information
singiamtel committed Nov 14, 2024
1 parent 2320045 commit 219850c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion alibuild_helpers/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ def getstatusoutput(command, timeout=None):
return proc.returncode, merged_output


def execute(command, printer=debug, timeout=None):
def execute(command: str | list[str], printer=debug, timeout:int | None =None) -> int:
popen = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=STDOUT)
start_time = time.time()
assert popen.stdout is not None, "Could not open stdout for command"
for line in iter(popen.stdout.readline, b""):
printer("%s", decode_with_fallback(line).strip("\n"))
if timeout is not None and time.time() > start_time + timeout:
Expand Down
4 changes: 2 additions & 2 deletions alibuild_helpers/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from alibuild_helpers.utilities import getPackageList, parseDefaults, readDefaults, validateDefaults
from alibuild_helpers.cmd import getstatusoutput, DockerRunner

def prunePaths(workDir):
def prunePaths(workDir: str) -> None:
for x in ["PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH"]:
if not x in os.environ:
continue
Expand Down Expand Up @@ -52,7 +52,7 @@ def checkRequirements(spec, cmd, homebrew_replacement, getstatusoutput_docker):
spec.get("system_requirement_missing"))
return (err, "")

def systemInfo():
def systemInfo() -> None:
_,out = getstatusoutput("env")
debug("Environment:\n%s", out)
_,out = getstatusoutput("uname -a")
Expand Down
2 changes: 1 addition & 1 deletion alibuild_helpers/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os.path as path
import os, sys

def parsePackagesDefinition(pkgname):
def parsePackagesDefinition(pkgname: str):
return [ dict(zip(["name","ver"], y.split("@")[0:2]))
for y in [ x+"@" for x in list(filter(lambda y: y, pkgname.split(","))) ] ]

Expand Down

0 comments on commit 219850c

Please sign in to comment.