Skip to content

Commit addaaac

Browse files
committed
docs(subproces): Module-level documentation
1 parent 1ea6a98 commit addaaac

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

libvcs/utils/subprocess.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
"""Invokable subprocess wrapper.
2+
3+
Defer running a subprocess, such as by handing to an executor.
4+
5+
- :class:`~SubprocessCommand`: Wraps :class:`subprocess.Popen` and
6+
:func:`subprocess.run` in a :func:`~dataclasses.dataclass`.
7+
8+
Before:
9+
10+
>>> import subprocess
11+
>>> subprocess.run(
12+
... ['echo', 'hi'],
13+
... capture_output=True, universal_newlines=True
14+
... ).stdout
15+
'hi\\n'
16+
17+
With this:
18+
19+
>>> cmd = SubprocessCommand(['echo', 'hi'])
20+
>>> cmd.args
21+
['echo', 'hi']
22+
>>> cmd.run(capture_output=True, universal_newlines=True).stdout
23+
'hi\\n'
24+
25+
Tweak params before invocation:
26+
27+
>>> cmd = SubprocessCommand(['echo', 'hi'])
28+
>>> cmd.args[1] = 'hello'
29+
>>> cmd.args
30+
['echo', 'hello']
31+
>>> cmd.run(capture_output=True, universal_newlines=True).stdout
32+
'hello\\n'
33+
"""
134
import dataclasses
235
import subprocess
336
import sys

0 commit comments

Comments
 (0)