From d5e330e6aae07f59afaf8d88fde923087c57375e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 24 Dec 2023 08:45:23 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Tests/test_file_vtf.py | 6 +++--- src/PIL/VtfImagePlugin.py | 44 ++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Tests/test_file_vtf.py b/Tests/test_file_vtf.py index d84981885..62a6ad47d 100644 --- a/Tests/test_file_vtf.py +++ b/Tests/test_file_vtf.py @@ -1,4 +1,4 @@ -from typing import Tuple +from __future__ import annotations import pytest @@ -42,7 +42,7 @@ def test_closest_power(size: int, expected_size: int): ((1024, 1), 11), ], ) -def test_get_mipmap_count(size: Tuple[int, int], expected_count: int): +def test_get_mipmap_count(size: tuple[int, int], expected_count: int): assert _get_mipmap_count(*size) == expected_count @@ -63,7 +63,7 @@ def test_get_mipmap_count(size: Tuple[int, int], expected_count: int): ], ) def test_get_texture_size( - pixel_format: VtfPF, size: Tuple[int, int], expected_size: int + pixel_format: VtfPF, size: tuple[int, int], expected_size: int ): assert _get_texture_size(pixel_format, *size) == expected_size diff --git a/src/PIL/VtfImagePlugin.py b/src/PIL/VtfImagePlugin.py index bea11ae16..8d5e0de4e 100644 --- a/src/PIL/VtfImagePlugin.py +++ b/src/PIL/VtfImagePlugin.py @@ -9,6 +9,7 @@ The contents of this file are hereby released in the public domain (CC0) Full text of the CC0 license: https://creativecommons.org/publicdomain/zero/1.0/ """ +from __future__ import annotations import struct from enum import IntEnum, IntFlag @@ -101,30 +102,25 @@ class VtfPF(IntEnum): # UVLX8888 = 26 -VTFHeader = NamedTuple( - "VTFHeader", - [ - ("header_size", int), - ("width", int), - ("height", int), - ("flags", int), - ("frames", int), - ("first_frames", int), - ("reflectivity_r", float), - ("reflectivity_g", float), - ("reflectivity_b", float), - ("bumpmap_scale", float), - ("pixel_format", int), - ("mipmap_count", int), - ("low_pixel_format", int), - ("low_width", int), - ("low_height", int), - # V 7.2+ - ("depth", int), - # V 7.3+ - ("resource_count", int), - ], -) +class VTFHeader(NamedTuple): + header_size: int + width: int + height: int + flags: int + frames: int + first_frames: int + reflectivity_r: float + reflectivity_g: float + reflectivity_b: float + bumpmap_scale: float + pixel_format: int + mipmap_count: int + low_pixel_format: int + low_width: int + low_height: int + depth: int + resource_count: int + BLOCK_COMPRESSED = (VtfPF.DXT1, VtfPF.DXT1_ONEBITALPHA, VtfPF.DXT3, VtfPF.DXT5) HEADER_V70 = "