Skip to content

Commit 3cd97d5

Browse files
committed
pre-commit: update pyupgrade 1.18.0 -> 2.2.1
1 parent 23881ad commit 3cd97d5

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ repos:
3232
- id: reorder-python-imports
3333
args: ['--application-directories=.:src', --py3-plus]
3434
- repo: https://github.com/asottile/pyupgrade
35-
rev: v1.18.0
35+
rev: v2.2.1
3636
hooks:
3737
- id: pyupgrade
3838
args: [--py3-plus]

src/_pytest/capture.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def __init__(self, targetfd, tmpfile=None):
505505
self.done = self._done
506506
if targetfd == 0:
507507
assert not tmpfile, "cannot set tmpfile with stdin"
508-
tmpfile = open(os.devnull, "r")
508+
tmpfile = open(os.devnull)
509509
self.syscapture = SysCapture(targetfd)
510510
else:
511511
if tmpfile is None:
@@ -580,7 +580,7 @@ class FDCapture(FDCaptureBinary):
580580
"""
581581

582582
# Ignore type because it doesn't match the type in the superclass (bytes).
583-
EMPTY_BUFFER = str() # type: ignore
583+
EMPTY_BUFFER = "" # type: ignore
584584

585585
def snap(self):
586586
self.tmpfile.seek(0)
@@ -651,7 +651,7 @@ def writeorg(self, data):
651651

652652

653653
class SysCapture(SysCaptureBinary):
654-
EMPTY_BUFFER = str() # type: ignore[assignment] # noqa: F821
654+
EMPTY_BUFFER = "" # type: ignore[assignment] # noqa: F821
655655

656656
def snap(self):
657657
res = self.tmpfile.getvalue()

src/_pytest/pytester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,8 @@ def handle_timeout():
12021202
finally:
12031203
f1.close()
12041204
f2.close()
1205-
f1 = open(str(p1), "r", encoding="utf8")
1206-
f2 = open(str(p2), "r", encoding="utf8")
1205+
f1 = open(str(p1), encoding="utf8")
1206+
f2 = open(str(p2), encoding="utf8")
12071207
try:
12081208
out = f1.read().splitlines()
12091209
err = f2.read().splitlines()

testing/acceptance_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ def test_simple():
13391339
result.stderr.fnmatch_lines(["*@this is stderr@*"])
13401340

13411341
# now ensure the output is in the junitxml
1342-
with open(os.path.join(testdir.tmpdir.strpath, "output.xml"), "r") as f:
1342+
with open(os.path.join(testdir.tmpdir.strpath, "output.xml")) as f:
13431343
fullXml = f.read()
13441344
assert "@this is stdout@\n" in fullXml
13451345
assert "@this is stderr@\n" in fullXml

testing/logging/test_reporting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,11 +1103,11 @@ def test_second():
11031103
"""
11041104
)
11051105
testdir.runpytest()
1106-
with open(os.path.join(report_dir_base, "test_first"), "r") as rfh:
1106+
with open(os.path.join(report_dir_base, "test_first")) as rfh:
11071107
content = rfh.read()
11081108
assert "message from test 1" in content
11091109

1110-
with open(os.path.join(report_dir_base, "test_second"), "r") as rfh:
1110+
with open(os.path.join(report_dir_base, "test_second")) as rfh:
11111111
content = rfh.read()
11121112
assert "message from test 2" in content
11131113

testing/test_capture.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,14 +1401,14 @@ def test_global(fix1):
14011401
result = testdir.runpytest_subprocess("--log-cli-level=INFO")
14021402
assert result.ret == 0
14031403

1404-
with open("caplog", "r") as f:
1404+
with open("caplog") as f:
14051405
caplog = f.read()
14061406

14071407
assert "fix setup" in caplog
14081408
assert "something in test" in caplog
14091409
assert "fix teardown" in caplog
14101410

1411-
with open("capstdout", "r") as f:
1411+
with open("capstdout") as f:
14121412
capstdout = f.read()
14131413

14141414
assert "fix setup" in capstdout

0 commit comments

Comments
 (0)