Skip to content

Commit 090ca94

Browse files
committed
PERF403 and fixes
1 parent 9a358fa commit 090ca94

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ lint.select = [
150150
"PERF102", # perflint: incorrect-dict-iterator
151151
"PERF401", # perflint: manual-list-comprehension
152152
"PERF402", # perflint: manual-list-copy
153+
"PERF403", # perflint: manual-dict-comprehension
153154
"PGH", # pygrep-hooks
154155
"PIE", # flake8-pie
155156
"PT", # flake8-pytest-style

src/PIL/IptcImagePlugin.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,9 @@ def getiptcinfo(
185185

186186
data = None
187187

188-
info: dict[tuple[int, int], bytes | list[bytes]] = {}
189188
if isinstance(im, IptcImageFile):
190189
# return info dictionary right away
191-
for k, v in im.info.items():
192-
if isinstance(k, tuple):
193-
info[k] = v
194-
return info
190+
return {k: v for k, v in im.info.items() if isinstance(k, tuple)}
195191

196192
elif isinstance(im, JpegImagePlugin.JpegImageFile):
197193
# extract the IPTC/NAA resource
@@ -227,7 +223,4 @@ class FakeImage:
227223
except (IndexError, KeyError):
228224
pass # expected failure
229225

230-
for k, v in iptc_im.info.items():
231-
if isinstance(k, tuple):
232-
info[k] = v
233-
return info
226+
return {k: v for k, v in iptc_im.info.items() if isinstance(k, tuple)}

0 commit comments

Comments
 (0)