ruff icon indicating copy to clipboard operation
ruff copied to clipboard

PyUpgrade: Replace pipes with `capture_output=True`

Open colin99d opened this issue 2 years ago • 6 comments

Creating this PR for visibility. It will remain a draft until the following two issues are resolved:

  • I am not sure how to avoid double counting errors, since there are two different ranges and two different fixes need to be applied.
  • Currently the autofix::Fix::deletion seems to be leaving extra dangling commas and spaces. I am assuming this is my error, and will dig in for a fix.

Update: Both of these fixed, lets get this merged.

A part of #827

colin99d avatar Dec 28 '22 01:12 colin99d

Sweet, will review today.

charliermarsh avatar Dec 28 '22 16:12 charliermarsh

May I suggest to include test cases from pyupgrade? https://github.com/asottile/pyupgrade/blob/main/tests/features/capture_output_test.py

Examples I don't see covered:

run(["foo"], stdout=None, stderr=PIPE)

from foo import PIPE
from subprocess import run
subprocess.run(["foo"], stdout=PIPE, stderr=PIPE)

squiddy avatar Dec 28 '22 16:12 squiddy

(Oh, yes please, I forgot that we were including the pyupgrade test cases.)

charliermarsh avatar Dec 28 '22 16:12 charliermarsh

I will add them for both of my PRs

colin99d avatar Dec 28 '22 16:12 colin99d

🙏 Thank you

charliermarsh avatar Dec 28 '22 16:12 charliermarsh

She passed em flawlessly!

colin99d avatar Dec 28 '22 16:12 colin99d