Skip to content

Commit a70736a

Browse files
isHarryhK0lb3
authored andcommitted
fix(files): use generic type in EndianBinaryWriter
1 parent f039c28 commit a70736a

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

‎UnityPy/streams/EndianBinaryWriter.py‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
from io import BytesIO, IOBase
33

44
import builtins
5-
from typing import Callable, Sequence, Union
5+
from typing import Callable, Sequence, TypeVar, Union
66

77
from ..math import Color, Matrix4x4, Quaternion, Vector2, Vector3, Vector4, Rectangle
88

9+
T = TypeVar("T")
10+
911

1012
class EndianBinaryWriter:
1113
endian: str
@@ -144,7 +146,7 @@ def write_matrix(self, value: Matrix4x4):
144146
for val in value.M:
145147
self.write_float(val)
146148

147-
def write_array(self, command: Callable, value: Sequence, write_length: bool = True):
149+
def write_array(self, command: Callable[[T], None], value: Sequence[T], write_length: bool = True):
148150
if write_length:
149151
self.write_int(len(value))
150152
for val in value:
@@ -154,29 +156,29 @@ def write_byte_array(self, value: builtins.bytes):
154156
self.write_int(len(value))
155157
self.write(value)
156158

157-
def write_boolean_array(self, value: Sequence):
159+
def write_boolean_array(self, value: Sequence[bool]):
158160
self.write_array(self.write_boolean, value)
159161

160-
def write_u_short_array(self, value: Sequence):
162+
def write_u_short_array(self, value: Sequence[int]):
161163
self.write_array(self.write_u_short, value)
162164

163-
def write_int_array(self, value: Sequence, write_length: bool = False):
165+
def write_int_array(self, value: Sequence[int], write_length: bool = False):
164166
return self.write_array(self.write_int, value, write_length)
165167

166-
def write_u_int_array(self, value: Sequence, write_length: bool = False):
168+
def write_u_int_array(self, value: Sequence[int], write_length: bool = False):
167169
return self.write_array(self.write_u_int, value, write_length)
168170

169-
def write_float_array(self, value: Sequence, write_length: bool = False):
171+
def write_float_array(self, value: Sequence[float], write_length: bool = False):
170172
return self.write_array(self.write_float, value, write_length)
171173

172-
def write_string_array(self, value: Sequence):
174+
def write_string_array(self, value: Sequence[str]):
173175
self.write_array(self.write_aligned_string, value)
174176

175-
def write_vector2_array(self, value: Sequence):
177+
def write_vector2_array(self, value: Sequence[Vector2]):
176178
self.write_array(self.write_vector2, value)
177179

178-
def write_vector4_array(self, value: Sequence):
180+
def write_vector4_array(self, value: Sequence[Vector4]):
179181
self.write_array(self.write_vector4, value)
180182

181-
def write_matrix_array(self, value: Sequence):
183+
def write_matrix_array(self, value: Sequence[Matrix4x4]):
182184
self.write_array(self.write_matrix, value)

0 commit comments

Comments
 (0)