Skip to content

Commit 66eef36

Browse files
committed
Improved typing for NO_DEFAULT
1 parent 006756c commit 66eef36

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

pgvector/sparsevec.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
from __future__ import annotations
22
from struct import pack, unpack_from
3-
from typing import TYPE_CHECKING, Any, overload
3+
from typing import TYPE_CHECKING, Final, overload
44
from ._utils import is_sparse_array, ndarray
55

66
if TYPE_CHECKING:
77
import numpy as np
88
from scipy.sparse import sparray, spmatrix, coo_array, coo_matrix
99

1010

11-
NO_DEFAULT = object()
11+
class Sentinel:
12+
pass
13+
14+
15+
NO_DEFAULT: Final[Sentinel] = Sentinel()
1216

1317

1418
class SparseVector:
@@ -20,7 +24,7 @@ def __init__(self, value: dict[int, float], dimensions: int, /) -> None:
2024
def __init__(self, value: list[float] | ndarray | sparray | spmatrix, /) -> None:
2125
...
2226

23-
def __init__(self, value: dict[int, float] | list[float] | ndarray | sparray | spmatrix, dimensions: int | Any = NO_DEFAULT, /) -> None:
27+
def __init__(self, value: dict[int, float] | list[float] | ndarray | sparray | spmatrix, dimensions: int | Sentinel = NO_DEFAULT, /) -> None:
2428
if is_sparse_array(value):
2529
if dimensions is not NO_DEFAULT:
2630
raise ValueError('extra argument')

0 commit comments

Comments
 (0)