Skip to content

Commit b4b684d

Browse files
committed
Improved type hints [skip ci]
1 parent 03bbac7 commit b4b684d

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

pgvector/bit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, value: Any) -> None:
3131
def __repr__(self) -> str:
3232
return f'Bit({self.to_text()})'
3333

34-
def __eq__(self, other: Any) -> bool:
34+
def __eq__(self, other: object) -> bool:
3535
if isinstance(other, self.__class__):
3636
return self._len == other._len and self._data == other._data
3737
return False

pgvector/halfvec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, value: Any) -> None:
1818
def __repr__(self) -> str:
1919
return f'HalfVector({self.to_list()})'
2020

21-
def __eq__(self, other: Any) -> bool:
21+
def __eq__(self, other: object) -> bool:
2222
if isinstance(other, self.__class__):
2323
return np.array_equal(self.to_numpy(), other.to_numpy())
2424
return False
@@ -48,7 +48,7 @@ def from_binary(cls, value: bytes) -> HalfVector:
4848
return cls(np.frombuffer(value, dtype='>f2', count=dim, offset=4))
4949

5050
@classmethod
51-
def _to_db(cls, value: Any, dim: int | None = None) -> str | None:
51+
def _to_db(cls, value: object, dim: int | None = None) -> str | None:
5252
if value is None:
5353
return value
5454

@@ -61,7 +61,7 @@ def _to_db(cls, value: Any, dim: int | None = None) -> str | None:
6161
return value.to_text()
6262

6363
@classmethod
64-
def _to_db_binary(cls, value: Any) -> bytes | None:
64+
def _to_db_binary(cls, value: object) -> bytes | None:
6565
if value is None:
6666
return value
6767

pgvector/sparsevec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __repr__(self) -> str:
2828
elements = dict(zip(self._indices, self._values))
2929
return f'SparseVector({elements}, {self._dim})'
3030

31-
def __eq__(self, other: Any) -> bool:
31+
def __eq__(self, other: object) -> bool:
3232
if isinstance(other, self.__class__):
3333
return self.dimensions() == other.dimensions() and self.indices() == other.indices() and self.values() == other.values()
3434
return False
@@ -126,7 +126,7 @@ def _from_parts(cls, dim: int, indices: list[int], values: list[float]) -> Spars
126126
return vec
127127

128128
@classmethod
129-
def _to_db(cls, value: Any, dim: int | None = None) -> str | None:
129+
def _to_db(cls, value: object, dim: int | None = None) -> str | None:
130130
if value is None:
131131
return value
132132

@@ -139,7 +139,7 @@ def _to_db(cls, value: Any, dim: int | None = None) -> str | None:
139139
return value.to_text()
140140

141141
@classmethod
142-
def _to_db_binary(cls, value: Any) -> bytes | None:
142+
def _to_db_binary(cls, value: object) -> bytes | None:
143143
if value is None:
144144
return value
145145

pgvector/vector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, value: Any) -> None:
1818
def __repr__(self) -> str:
1919
return f'Vector({self.to_list()})'
2020

21-
def __eq__(self, other: Any) -> bool:
21+
def __eq__(self, other: object) -> bool:
2222
if isinstance(other, self.__class__):
2323
return np.array_equal(self.to_numpy(), other.to_numpy())
2424
return False
@@ -48,7 +48,7 @@ def from_binary(cls, value: bytes) -> Vector:
4848
return cls(np.frombuffer(value, dtype='>f4', count=dim, offset=4))
4949

5050
@classmethod
51-
def _to_db(cls, value: Any, dim: int | None = None) -> str | None:
51+
def _to_db(cls, value: object, dim: int | None = None) -> str | None:
5252
if value is None:
5353
return value
5454

@@ -61,7 +61,7 @@ def _to_db(cls, value: Any, dim: int | None = None) -> str | None:
6161
return value.to_text()
6262

6363
@classmethod
64-
def _to_db_binary(cls, value: Any) -> bytes | None:
64+
def _to_db_binary(cls, value: object) -> bytes | None:
6565
if value is None:
6666
return value
6767

0 commit comments

Comments
 (0)