@@ -446,6 +446,19 @@ def __repr__(self):
446446 args .append ('stderr={!r}' .format (self .stderr ))
447447 return "{}({})" .format (type (self ).__name__ , ', ' .join (args ))
448448
449+ def __class_getitem__ (cls , type ):
450+ """Provide minimal support for using this class as generic
451+ (for example in type annotations).
452+
453+ See PEP 484 and PEP 560 for more details. For example,
454+ `CompletedProcess[bytes]` is a valid expression at runtime
455+ (type argument `bytes` indicates the type used for stdout).
456+ Note, no type checking happens at runtime, but a static type
457+ checker can be used.
458+ """
459+ return cls
460+
461+
449462 def check_returncode (self ):
450463 """Raise CalledProcessError if the exit code is non-zero."""
451464 if self .returncode :
@@ -987,6 +1000,17 @@ def __repr__(self):
9871000 obj_repr = obj_repr [:76 ] + "...>"
9881001 return obj_repr
9891002
1003+ def __class_getitem__ (cls , type ):
1004+ """Provide minimal support for using this class as generic
1005+ (for example in type annotations).
1006+
1007+ See PEP 484 and PEP 560 for more details. For example, `Popen[bytes]`
1008+ is a valid expression at runtime (type argument `bytes` indicates the
1009+ type used for stdout). Note, no type checking happens at runtime, but
1010+ a static type checker can be used.
1011+ """
1012+ return cls
1013+
9901014 @property
9911015 def universal_newlines (self ):
9921016 # universal_newlines as retained as an alias of text_mode for API
0 commit comments