Skip to content

Commit b85b853

Browse files
committed
PERF401 and fixes
1 parent 624fc87 commit b85b853

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ lint.select = [
148148
"LOG", # flake8-logging
149149
"PERF101", # perflint: unnecessary-list-cast
150150
"PERF102", # perflint: incorrect-dict-iterator
151+
"PERF401", # perflint: manual-list-comprehension
151152
"PGH", # pygrep-hooks
152153
"PIE", # flake8-pie
153154
"PT", # flake8-pytest-style

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,10 +1078,10 @@ def debug_build() -> bool:
10781078
]
10791079

10801080
files: list[str | os.PathLike[str]] = ["src/_imaging.c"]
1081-
for src_file in _IMAGING:
1082-
files.append("src/" + src_file + ".c")
1083-
for src_file in _LIB_IMAGING:
1084-
files.append(os.path.join("src/libImaging", src_file + ".c"))
1081+
files.extend("src/" + src_file + ".c" for src_file in _IMAGING)
1082+
files.extend(
1083+
os.path.join("src/libImaging", src_file + ".c") for src_file in _LIB_IMAGING
1084+
)
10851085
ext_modules = [
10861086
Extension("PIL._imaging", files),
10871087
Extension("PIL._imagingft", ["src/_imagingft.c"]),

src/PIL/IcnsImagePlugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ def read_32(
8080
if byte_int & 0x80:
8181
blocksize = byte_int - 125
8282
byte = fobj.read(1)
83-
for i in range(blocksize):
84-
data.append(byte)
83+
data.extend([byte] * blocksize)
8584
else:
8685
blocksize = byte_int + 1
8786
data.append(fobj.read(blocksize))

src/PIL/ImageDraw.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,7 @@ def draw_text(ink: int, stroke_width: float = 0) -> None:
597597
mode = self.fontmode
598598
if stroke_width == 0 and embedded_color:
599599
mode = "RGBA"
600-
coord = []
601-
for i in range(2):
602-
coord.append(int(xy[i]))
600+
coord = [int(xy[i]) for i in range(2)]
603601
start = (math.modf(xy[0])[0], math.modf(xy[1])[0])
604602
try:
605603
mask, offset = image_text.font.getmask2( # type: ignore[union-attr,misc]

src/PIL/ImageFile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ def get_child_images(self) -> list[ImageFile]:
215215
if subifd_offsets:
216216
if not isinstance(subifd_offsets, tuple):
217217
subifd_offsets = (subifd_offsets,)
218-
for subifd_offset in subifd_offsets:
219-
ifds.append((exif._get_ifd_dict(subifd_offset), subifd_offset))
218+
ifds = [
219+
(exif._get_ifd_dict(subifd_offset), subifd_offset)
220+
for subifd_offset in subifd_offsets
221+
]
220222
ifd1 = exif.get_ifd(ExifTags.IFD.IFD1)
221223
if ifd1 and ifd1.get(ExifTags.Base.JpegIFOffset):
222224
assert exif._info is not None

winbuild/build_prepare.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,11 @@ def write_script(
544544
def get_footer(dep: dict[str, Any]) -> list[str]:
545545
lines = []
546546
for out in dep.get("headers", []):
547-
lines.append(cmd_copy(out, "{inc_dir}"))
547+
lines.append(cmd_copy(out, "{inc_dir}")) # noqa: PERF401
548548
for out in dep.get("libs", []):
549-
lines.append(cmd_copy(out, "{lib_dir}"))
549+
lines.append(cmd_copy(out, "{lib_dir}")) # noqa: PERF401
550550
for out in dep.get("bins", []):
551-
lines.append(cmd_copy(out, "{bin_dir}"))
551+
lines.append(cmd_copy(out, "{bin_dir}")) # noqa: PERF401
552552
return lines
553553

554554

0 commit comments

Comments
 (0)