Skip to content

Commit 458de80

Browse files
jdufresneDimitriPapadopoulos
authored andcommitted
Update subprocess usage to use modern subprocess.run()
https://docs.python.org/3/library/subprocess.html#subprocess.run > The recommended approach to invoking subprocesses is to use the run() > function for all use cases it can handle.
1 parent 7a08d9f commit 458de80

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

codespell_lib/tests/test_basic.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ def main(self, *args, count=True, std=False, **kwargs):
4747
def run_codespell(args=(), cwd=None):
4848
"""Run codespell."""
4949
args = ('--count',) + args
50-
proc = subprocess.Popen(
50+
proc = subprocess.run(
5151
['codespell'] + list(args), cwd=cwd,
52-
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
53-
stderr = proc.communicate()[1].decode('utf-8')
54-
count = int(stderr.split('\n')[-2])
52+
capture_output=True, encoding='utf-8')
53+
count = int(proc.stderr.split('\n')[-2])
5554
return count
5655

5756

0 commit comments

Comments
 (0)