summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index ba6f198..30f0d1b 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -446,6 +446,19 @@ class CompletedProcess(object):
args.append('stderr={!r}'.format(self.stderr))
return "{}({})".format(type(self).__name__, ', '.join(args))
+ def __class_getitem__(cls, type):
+ """Provide minimal support for using this class as generic
+ (for example in type annotations).
+
+ See PEP 484 and PEP 560 for more details. For example,
+ `CompletedProcess[bytes]` is a valid expression at runtime
+ (type argument `bytes` indicates the type used for stdout).
+ Note, no type checking happens at runtime, but a static type
+ checker can be used.
+ """
+ return cls
+
+
def check_returncode(self):
"""Raise CalledProcessError if the exit code is non-zero."""
if self.returncode:
@@ -987,6 +1000,17 @@ class Popen(object):
obj_repr = obj_repr[:76] + "...>"
return obj_repr
+ def __class_getitem__(cls, type):
+ """Provide minimal support for using this class as generic
+ (for example in type annotations).
+
+ See PEP 484 and PEP 560 for more details. For example, `Popen[bytes]`
+ is a valid expression at runtime (type argument `bytes` indicates the
+ type used for stdout). Note, no type checking happens at runtime, but
+ a static type checker can be used.
+ """
+ return cls
+
@property
def universal_newlines(self):
# universal_newlines as retained as an alias of text_mode for API