Skip to content

Commit 5753e3b

Browse files
committed
Adds numpy.typing.NDArray
1 parent b7556fb commit 5753e3b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bson/binary.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
_NUMPY_AVAILABLE = False
7070
try:
7171
import numpy as np
72+
import numpy.typing as npt
7273

7374
_NUMPY_AVAILABLE = True
7475
except ImportError:
@@ -446,7 +447,7 @@ def from_vector(
446447
@overload
447448
def from_vector(
448449
cls: Type[Binary],
449-
vector: np.ndarray,
450+
vector: npt.NDArray[np.number],
450451
dtype: BinaryVectorDtype,
451452
padding: int = 0,
452453
) -> Binary:
@@ -455,7 +456,7 @@ def from_vector(
455456
@classmethod
456457
def from_vector(
457458
cls: Type[Binary],
458-
vector: Union[BinaryVector, list[int], list[float], np.ndarray],
459+
vector: Union[BinaryVector, list[int], list[float], npt.NDArray[np.number]],
459460
dtype: Optional[BinaryVectorDtype] = None,
460461
padding: Optional[int] = None,
461462
) -> Binary:
@@ -638,7 +639,7 @@ def __repr__(self) -> str:
638639

639640

640641
def _numpy_vector_to_bytes(
641-
vector: np.ndarray,
642+
vector: npt.NDArray[np.number],
642643
dtype: BinaryVectorDtype,
643644
) -> bytes:
644645
if not _NUMPY_AVAILABLE:

0 commit comments

Comments
 (0)