Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added default values for _Tile offset and args #8553

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PIL/BlpImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
raise BLPFormatError(msg)

self._mode = "RGBA" if self._blp_alpha_depth else "RGB"
self.tile = [ImageFile._Tile(decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))]
self.tile = [ImageFile._Tile(decoder, (0, 0) + self.size, 0, self.mode)]

Check warning on line 276 in src/PIL/BlpImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/BlpImagePlugin.py#L276

Added line #L276 was not covered by tests


class _BLPBaseDecoder(ImageFile.PyDecoder):
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,7 @@
+ struct.pack("<4I", *rgba_mask) # dwRGBABitMask
+ struct.pack("<5I", DDSCAPS.TEXTURE, 0, 0, 0, 0)
)
ImageFile._save(
im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))]
)
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, rawmode)])

Check warning on line 563 in src/PIL/DdsImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/DdsImagePlugin.py#L563

Added line #L563 was not covered by tests


def _accept(prefix: bytes) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
if hasattr(fp, "flush"):
fp.flush()

ImageFile._save(im, fp, [ImageFile._Tile("eps", (0, 0) + im.size, 0, None)])
ImageFile._save(im, fp, [ImageFile._Tile("eps", (0, 0) + im.size)])

Check warning on line 457 in src/PIL/EpsImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/EpsImagePlugin.py#L457

Added line #L457 was not covered by tests

fp.write(b"\n%%%%EndBinary\n")
fp.write(b"grestore end\n")
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/FliImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
framesize = i32(s)

self.decodermaxblock = framesize
self.tile = [ImageFile._Tile("fli", (0, 0) + self.size, self.__offset, None)]
self.tile = [ImageFile._Tile("fli", (0, 0) + self.size, self.__offset)]

Check warning on line 162 in src/PIL/FliImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/FliImagePlugin.py#L162

Added line #L162 was not covered by tests

self.__offset += framesize

Expand Down
2 changes: 1 addition & 1 deletion src/PIL/FpxImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _open_subimage(self, index: int = 1, subimage: int = 0) -> None:
"raw",
(x, y, x1, y1),
i32(s, i) + 28,
(self.rawmode,),
self.rawmode,
)
)

Expand Down
2 changes: 1 addition & 1 deletion src/PIL/FtexImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
self._mode = "RGBA"
self.tile = [ImageFile._Tile("bcn", (0, 0) + self.size, 0, (1,))]
elif format == Format.UNCOMPRESSED:
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 0, ("RGB", 0, 1))]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 0, "RGB")]

Check warning on line 98 in src/PIL/FtexImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/FtexImagePlugin.py#L98

Added line #L98 was not covered by tests
else:
msg = f"Invalid texture compression format: {repr(format)}"
raise ValueError(msg)
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/GdImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _open(self) -> None:
"raw",
(0, 0) + self.size,
7 + true_color_offset + 4 + 256 * 4,
("L", 0, 1),
"L",
)
]

Expand Down
4 changes: 2 additions & 2 deletions src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
class _Tile(NamedTuple):
codec_name: str
extents: tuple[int, int, int, int] | None
offset: int
args: tuple[Any, ...] | str | None
offset: int = 0
args: tuple[Any, ...] | str | None = None

Check warning on line 102 in src/PIL/ImageFile.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/ImageFile.py#L101-L102

Added lines #L101 - L102 were not covered by tests


#
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/ImtImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _open(self) -> None:
"raw",
(0, 0) + self.size,
self.fp.tell() - len(buffer),
(self.mode, 0, 1),
self.mode,
)
]

Expand Down
6 changes: 3 additions & 3 deletions src/PIL/MspImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
self._size = i16(s, 4), i16(s, 6)

if s[:4] == b"DanM":
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 32, ("1", 0, 1))]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 32, "1")]

Check warning on line 73 in src/PIL/MspImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/MspImagePlugin.py#L73

Added line #L73 was not covered by tests
else:
self.tile = [ImageFile._Tile("MSP", (0, 0) + self.size, 32, None)]
self.tile = [ImageFile._Tile("MSP", (0, 0) + self.size, 32)]

Check warning on line 75 in src/PIL/MspImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/MspImagePlugin.py#L75

Added line #L75 was not covered by tests


class MspDecoder(ImageFile.PyDecoder):
Expand Down Expand Up @@ -188,7 +188,7 @@
fp.write(o16(h))

# image body
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 32, ("1", 0, 1))])
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 32, "1")])

Check warning on line 191 in src/PIL/MspImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/MspImagePlugin.py#L191

Added line #L191 was not covered by tests


#
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/PcdImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

self._mode = "RGB"
self._size = 768, 512 # FIXME: not correct for rotated images!
self.tile = [ImageFile._Tile("pcd", (0, 0) + self.size, 96 * 2048, None)]
self.tile = [ImageFile._Tile("pcd", (0, 0) + self.size, 96 * 2048)]

Check warning on line 50 in src/PIL/PcdImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/PcdImagePlugin.py#L50

Added line #L50 was not covered by tests

def load_end(self) -> None:
if self.tile_post_rotate:
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/PixarImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
# FIXME: to be continued...

# create tile descriptor (assuming "dumped")
self.tile = [
ImageFile._Tile("raw", (0, 0) + self.size, 1024, (self.mode, 0, 1))
]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 1024, self.mode)]

Check warning on line 64 in src/PIL/PixarImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/PixarImagePlugin.py#L64

Added line #L64 was not covered by tests


#
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/QoiImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
self._mode = "RGB" if channels == 3 else "RGBA"

self.fp.seek(1, os.SEEK_CUR) # colorspace
self.tile = [ImageFile._Tile("qoi", (0, 0) + self._size, self.fp.tell(), None)]
self.tile = [ImageFile._Tile("qoi", (0, 0) + self._size, self.fp.tell())]

Check warning on line 35 in src/PIL/QoiImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/QoiImagePlugin.py#L35

Added line #L35 was not covered by tests


class QoiDecoder(ImageFile.PyDecoder):
Expand Down
8 changes: 2 additions & 6 deletions src/PIL/SpiderImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@
self.rawmode = "F;32F"
self._mode = "F"

self.tile = [
ImageFile._Tile("raw", (0, 0) + self.size, offset, (self.rawmode, 0, 1))
]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, offset, self.rawmode)]

Check warning on line 157 in src/PIL/SpiderImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/SpiderImagePlugin.py#L157

Added line #L157 was not covered by tests
self._fp = self.fp # FIXME: hack

@property
Expand Down Expand Up @@ -280,9 +278,7 @@
fp.writelines(hdr)

rawmode = "F;32NF" # 32-bit native floating point
ImageFile._save(
im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))]
)
ImageFile._save(im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, rawmode)])

Check warning on line 281 in src/PIL/SpiderImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/SpiderImagePlugin.py#L281

Added line #L281 was not covered by tests


def _save_spider(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/XVThumbImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def _open(self) -> None:
self.palette = ImagePalette.raw("RGB", PALETTE)

self.tile = [
ImageFile._Tile(
"raw", (0, 0) + self.size, self.fp.tell(), (self.mode, 0, 1)
)
ImageFile._Tile("raw", (0, 0) + self.size, self.fp.tell(), self.mode)
]


Expand Down
4 changes: 2 additions & 2 deletions src/PIL/XbmImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
self._mode = "1"
self._size = xsize, ysize

self.tile = [ImageFile._Tile("xbm", (0, 0) + self.size, m.end(), None)]
self.tile = [ImageFile._Tile("xbm", (0, 0) + self.size, m.end())]

Check warning on line 70 in src/PIL/XbmImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/XbmImagePlugin.py#L70

Added line #L70 was not covered by tests


def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
Expand All @@ -85,7 +85,7 @@

fp.write(b"static char im_bits[] = {\n")

ImageFile._save(im, fp, [ImageFile._Tile("xbm", (0, 0) + im.size, 0, None)])
ImageFile._save(im, fp, [ImageFile._Tile("xbm", (0, 0) + im.size)])

Check warning on line 88 in src/PIL/XbmImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/XbmImagePlugin.py#L88

Added line #L88 was not covered by tests

fp.write(b"};\n")

Expand Down
4 changes: 1 addition & 3 deletions src/PIL/XpmImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@
self._mode = "P"
self.palette = ImagePalette.raw("RGB", b"".join(palette))

self.tile = [
ImageFile._Tile("raw", (0, 0) + self.size, self.fp.tell(), ("P", 0, 1))
]
self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, self.fp.tell(), "P")]

Check warning on line 104 in src/PIL/XpmImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/XpmImagePlugin.py#L104

Added line #L104 was not covered by tests

def load_read(self, read_bytes: int) -> bytes:
#
Expand Down
Loading