Skip to content

Commit 2ec01c9

Browse files
committed
Added type hints
1 parent 64f992e commit 2ec01c9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/PIL/VtfImagePlugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ class VTFHeader(NamedTuple):
129129
HEADER_V73 = "<I2HI2H4x3f4xfIbI2bH3xI8x"
130130

131131

132-
def _get_texture_size(pixel_format: VtfPF, width, height):
132+
def _get_texture_size(pixel_format: VtfPF, width: int, height: int) -> int:
133133
if pixel_format in (VtfPF.DXT1, VtfPF.DXT1_ONEBITALPHA):
134134
return width * height // 2
135-
elif pixel_format in (VtfPF.DXT3, VtfPF.DXT5):
136-
return width * height
137135
elif pixel_format in (
136+
VtfPF.DXT3,
137+
VtfPF.DXT5,
138138
VtfPF.A8,
139139
VtfPF.I8,
140140
):
@@ -203,7 +203,7 @@ def _write_image(fp: IO[bytes], im: Image.Image, pixel_format: VtfPF) -> None:
203203
ImageFile._save(im, fp, tile, _get_texture_size(pixel_format, *im.size))
204204

205205

206-
def _closest_power(x):
206+
def _closest_power(x: int) -> int:
207207
possible_results = round(log(x, 2)), ceil(log(x, 2))
208208
return 2 ** min(possible_results, key=lambda z: abs(x - 2**z))
209209

0 commit comments

Comments
 (0)