Skip to content

Commit 27ca30d

Browse files
authored
Merge pull request #8309 from hugovk/flake8-pytest-style
Lint: run more flake8-pytest-style
2 parents eeb3d04 + 5747267 commit 27ca30d

File tree

7 files changed

+23
-12
lines changed

7 files changed

+23
-12
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.5.6
3+
rev: v0.6.0
44
hooks:
55
- id: ruff
66
args: [--exit-non-zero-on-fix]
77

88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 24.4.2
9+
rev: 24.8.0
1010
hooks:
1111
- id: black
1212

@@ -67,7 +67,7 @@ repos:
6767
- id: pyproject-fmt
6868

6969
- repo: https://github.com/abravalheri/validate-pyproject
70-
rev: v0.18
70+
rev: v0.19
7171
hooks:
7272
- id: validate-pyproject
7373

Tests/test_file_jpeg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,13 +1019,16 @@ def test_separate_tables(self) -> None:
10191019

10201020
# SOI, EOI
10211021
for marker in b"\xff\xd8", b"\xff\xd9":
1022-
assert marker in data[1] and marker in data[2]
1022+
assert marker in data[1]
1023+
assert marker in data[2]
10231024
# DHT, DQT
10241025
for marker in b"\xff\xc4", b"\xff\xdb":
1025-
assert marker in data[1] and marker not in data[2]
1026+
assert marker in data[1]
1027+
assert marker not in data[2]
10261028
# SOF0, SOS, APP0 (JFIF header)
10271029
for marker in b"\xff\xc0", b"\xff\xda", b"\xff\xe0":
1028-
assert marker not in data[1] and marker in data[2]
1030+
assert marker not in data[1]
1031+
assert marker in data[2]
10291032

10301033
with Image.open(BytesIO(data[0])) as interchange_im:
10311034
with Image.open(BytesIO(data[1] + data[2])) as combined_im:

Tests/test_file_jpeg2k.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def test_layers() -> None:
233233
("foo.jp2", {"no_jp2": True}, 0, b"\xff\x4f"),
234234
("foo.j2k", {"no_jp2": False}, 0, b"\xff\x4f"),
235235
("foo.jp2", {"no_jp2": False}, 4, b"jP"),
236-
("foo.jp2", {"no_jp2": False}, 4, b"jP"),
236+
(None, {"no_jp2": False}, 4, b"jP"),
237237
),
238238
)
239239
def test_no_jp2(name: str, args: dict[str, bool], offset: int, data: bytes) -> None:

Tests/test_imagechops.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ def table(
398398
for y in (a, b):
399399
imy = Image.new("1", (1, 1), y)
400400
value = op(imx, imy).getpixel((0, 0))
401-
assert not isinstance(value, tuple) and value is not None
401+
assert not isinstance(value, tuple)
402+
assert value is not None
402403
out.append(value)
403404
return out
404405

Tests/test_imagemorph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def img_to_string(im: Image.Image) -> str:
4646
line = ""
4747
for c in range(im.width):
4848
value = im.getpixel((c, r))
49-
assert not isinstance(value, tuple) and value is not None
49+
assert not isinstance(value, tuple)
50+
assert value is not None
5051
line += chars[value > 0]
5152
result.append(line)
5253
return "\n".join(result)

Tests/test_tiff_ifdrational.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def test_nonetype() -> None:
5454
assert xres.denominator is not None
5555
assert yres._val is not None
5656

57-
assert xres and 1
58-
assert xres and yres
57+
assert xres
58+
assert yres
5959

6060

6161
@pytest.mark.parametrize(

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ lint.select = [
109109
"ISC", # flake8-implicit-str-concat
110110
"LOG", # flake8-logging
111111
"PGH", # pygrep-hooks
112-
"PT006", # pytest-parametrize-names-wrong-type
112+
"PT", # flake8-pytest-style
113113
"PYI", # flake8-pyi
114114
"RUF100", # unused noqa (yesqa)
115115
"UP", # pyupgrade
@@ -121,6 +121,12 @@ lint.ignore = [
121121
"E221", # Multiple spaces before operator
122122
"E226", # Missing whitespace around arithmetic operator
123123
"E241", # Multiple spaces after ','
124+
"PT001", # pytest-fixture-incorrect-parentheses-style
125+
"PT007", # pytest-parametrize-values-wrong-type
126+
"PT011", # pytest-raises-too-broad
127+
"PT012", # pytest-raises-with-multiple-statements
128+
"PT016", # pytest-fail-without-message
129+
"PT017", # pytest-assert-in-except
124130
"PYI026", # flake8-pyi: typing.TypeAlias added in Python 3.10
125131
"PYI034", # flake8-pyi: typing.Self added in Python 3.11
126132
]

0 commit comments

Comments
 (0)