Skip to content

Commit f6fb996

Browse files
committed
Improved code [skip ci]
1 parent 56283d4 commit f6fb996

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎pgvector/bit.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def __eq__(self, other: object) -> bool:
6060
return False
6161

6262
def _length(self) -> int:
63-
length, = unpack_from('>i', self._value)
64-
return cast(int, length)
63+
length, = cast(tuple[int], unpack_from('>i', self._value))
64+
return length
6565

6666
def to_list(self) -> list[bool]:
6767
# TODO improve

‎pgvector/halfvec.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def __eq__(self, other: object) -> bool:
3838
return False
3939

4040
def dimensions(self) -> int:
41-
dim, = struct.unpack_from('>H', self._value)
42-
return cast(int, dim)
41+
dim, = cast(tuple[int], struct.unpack_from('>H', self._value))
42+
return dim
4343

4444
def to_list(self) -> list[float]:
4545
return list(struct.unpack_from(f'>{self.dimensions()}e', self._value[4:]))

‎pgvector/vector.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def __eq__(self, other: object) -> bool:
3838
return False
3939

4040
def dimensions(self) -> int:
41-
dim, = struct.unpack_from('>H', self._value)
42-
return cast(int, dim)
41+
dim, = cast(tuple[int], struct.unpack_from('>H', self._value))
42+
return dim
4343

4444
def to_list(self) -> list[float]:
4545
return list(struct.unpack_from(f'>{self.dimensions()}f', self._value[4:]))

0 commit comments

Comments
 (0)