aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-05-13 12:02:31 -0700
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-07-23 09:58:24 +0000
commit753587ee15a857df238d0c7a109eaf2613cb237f (patch)
tree5c3a47ab8d9e5788dc92dc01501eb204fe6744cd /mesonbuild/mesonlib.py
parent019f73dd7ca5d03d99ec32e2887bf20f32edc18a (diff)
downloadmeson-753587ee15a857df238d0c7a109eaf2613cb237f.zip
meson-753587ee15a857df238d0c7a109eaf2613cb237f.tar.gz
meson-753587ee15a857df238d0c7a109eaf2613cb237f.tar.bz2
mesonlib: Annotate Popen_safe functions
These are used in linkers.py and need to be annotated to make linkers.py 100% clean
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 3de6462..1223b2c 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -957,7 +957,10 @@ def expand_arguments(args):
return None
return expended_args
-def Popen_safe(args, write=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs):
+def Popen_safe(args: typing.List[str], write: typing.Optional[str] = None,
+ stdout: typing.Union[typing.BinaryIO, int] = subprocess.PIPE,
+ stderr: typing.Union[typing.BinaryIO, int] = subprocess.PIPE,
+ **kwargs: typing.Any) -> typing.Tuple[subprocess.Popen, str, str]:
import locale
encoding = locale.getpreferredencoding()
if sys.version_info < (3, 6) or not sys.stdout.encoding or encoding.upper() != 'UTF-8':
@@ -967,12 +970,16 @@ def Popen_safe(args, write=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
o, e = p.communicate(write)
return p, o, e
-def Popen_safe_legacy(args, write=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs):
+def Popen_safe_legacy(args: typing.List[str], write: typing.Optional[str] = None,
+ stdout: typing.Union[typing.BinaryIO, int] = subprocess.PIPE,
+ stderr: typing.Union[typing.BinaryIO, int] = subprocess.PIPE,
+ **kwargs: typing.Any) -> typing.Tuple[subprocess.Popen, str, str]:
p = subprocess.Popen(args, universal_newlines=False, close_fds=False,
stdout=stdout, stderr=stderr, **kwargs)
+ input_ = None # type: typing.Optional[bytes]
if write is not None:
- write = write.encode('utf-8')
- o, e = p.communicate(write)
+ input_ = write.encode('utf-8')
+ o, e = p.communicate(input_)
if o is not None:
if sys.stdout.encoding:
o = o.decode(encoding=sys.stdout.encoding, errors='replace').replace('\r\n', '\n')