@@ -61,17 +61,19 @@ def unpack_565(i: int) -> tuple[int, int, int]:
6161 return ((i >> 11 ) & 0x1F ) << 3 , ((i >> 5 ) & 0x3F ) << 2 , (i & 0x1F ) << 3
6262
6363
64- def decode_dxt1 (data , alpha = False ):
64+ def decode_dxt1 (
65+ data : bytes , alpha : bool = False
66+ ) -> tuple [bytearray , bytearray , bytearray , bytearray ]:
6567 """
6668 input: one "row" of data (i.e. will produce 4*width pixels)
6769 """
6870
6971 blocks = len (data ) // 8 # number of blocks in row
7072 ret = (bytearray (), bytearray (), bytearray (), bytearray ())
7173
72- for block in range (blocks ):
74+ for block_index in range (blocks ):
7375 # Decode next 8-byte block.
74- idx = block * 8
76+ idx = block_index * 8
7577 color0 , color1 , bits = struct .unpack_from ("<HHI" , data , idx )
7678
7779 r0 , g0 , b0 = unpack_565 (color0 )
@@ -116,16 +118,16 @@ def decode_dxt1(data, alpha=False):
116118 return ret
117119
118120
119- def decode_dxt3 (data ) :
121+ def decode_dxt3 (data : bytes ) -> tuple [ bytearray , bytearray , bytearray , bytearray ] :
120122 """
121123 input: one "row" of data (i.e. will produce 4*width pixels)
122124 """
123125
124126 blocks = len (data ) // 16 # number of blocks in row
125127 ret = (bytearray (), bytearray (), bytearray (), bytearray ())
126128
127- for block in range (blocks ):
128- idx = block * 16
129+ for block_index in range (blocks ):
130+ idx = block_index * 16
129131 block = data [idx : idx + 16 ]
130132 # Decode next 16-byte block.
131133 bits = struct .unpack_from ("<8B" , block )
@@ -169,16 +171,16 @@ def decode_dxt3(data):
169171 return ret
170172
171173
172- def decode_dxt5 (data ) :
174+ def decode_dxt5 (data : bytes ) -> tuple [ bytearray , bytearray , bytearray , bytearray ] :
173175 """
174176 input: one "row" of data (i.e. will produce 4 * width pixels)
175177 """
176178
177179 blocks = len (data ) // 16 # number of blocks in row
178180 ret = (bytearray (), bytearray (), bytearray (), bytearray ())
179181
180- for block in range (blocks ):
181- idx = block * 16
182+ for block_index in range (blocks ):
183+ idx = block_index * 16
182184 block = data [idx : idx + 16 ]
183185 # Decode next 16-byte block.
184186 a0 , a1 = struct .unpack_from ("<BB" , block )
0 commit comments