1616import struct
1717from dataclasses import dataclass
1818from enum import Enum
19- from typing import TYPE_CHECKING , Any , Optional , Sequence , Tuple , Type , Union
19+ from typing import TYPE_CHECKING , Any , Optional , Sequence , Tuple , Type , Union , overload
2020from uuid import UUID
2121
2222"""Tools for representing BSON binary data.
@@ -195,7 +195,7 @@ class UuidRepresentation:
195195
196196
197197VECTOR_SUBTYPE = 9
198- """**(BETA)** BSON binary subtype for densely packed vector data.
198+ """BSON binary subtype for densely packed vector data.
199199
200200.. versionadded:: 4.10
201201"""
@@ -207,7 +207,7 @@ class UuidRepresentation:
207207
208208
209209class BinaryVectorDtype (Enum ):
210- """**(BETA)** Datatypes of vector subtype.
210+ """Datatypes of vector subtype.
211211
212212 :param FLOAT32: (0x27) Pack list of :class:`float` as float32
213213 :param INT8: (0x03) Pack list of :class:`int` in [-128, 127] as signed int8
@@ -229,7 +229,7 @@ class BinaryVectorDtype(Enum):
229229
230230@dataclass
231231class BinaryVector :
232- """**(BETA)** Vector of numbers along with metadata for binary interoperability.
232+ """Vector of numbers along with metadata for binary interoperability.
233233 .. versionadded:: 4.10
234234 """
235235
@@ -256,7 +256,7 @@ class Binary(bytes):
256256 the difference between what should be considered binary data and
257257 what should be considered a string when we encode to BSON.
258258
259- **(BETA)** Subtype 9 provides a space-efficient representation of 1-dimensional vector data.
259+ Subtype 9 provides a space-efficient representation of 1-dimensional vector data.
260260 Its data is prepended with two bytes of metadata.
261261 The first (dtype) describes its data type, such as float32 or int8.
262262 The second (padding) prescribes the number of bits to ignore in the final byte.
@@ -278,7 +278,7 @@ class Binary(bytes):
278278 Support any bytes-like type that implements the buffer protocol.
279279
280280 .. versionchanged:: 4.10
281- **(BETA)** Addition of vector subtype.
281+ Addition of vector subtype.
282282 """
283283
284284 _type_marker = 5
@@ -397,14 +397,26 @@ def as_uuid(self, uuid_representation: int = UuidRepresentation.STANDARD) -> UUI
397397 f"cannot decode subtype { self .subtype } to { UUID_REPRESENTATION_NAMES [uuid_representation ]} "
398398 )
399399
400+ @classmethod
401+ @overload
402+ def from_vector (cls : Type [Binary ], vector : BinaryVector ) -> Binary :
403+ ...
404+
405+ @classmethod
406+ @overload
407+ def from_vector (
408+ cls : Type [Binary ], vector : list [int , float ], dtype : BinaryVectorDtype , padding : int = 0
409+ ) -> Binary :
410+ ...
411+
400412 @classmethod
401413 def from_vector (
402414 cls : Type [Binary ],
403415 vector : Union [BinaryVector , list [int , float ]],
404416 dtype : Optional [BinaryVectorDtype ] = None ,
405417 padding : Optional [int ] = None ,
406418 ) -> Binary :
407- """**(BETA)** Create a BSON :class:`~bson.binary.Binary` of Vector subtype.
419+ """Create a BSON :class:`~bson.binary.Binary` of Vector subtype.
408420
409421 To interpret the representation of the numbers, a data type must be included.
410422 See :class:`~bson.binary.BinaryVectorDtype` for available types and descriptions.
@@ -447,7 +459,7 @@ def from_vector(
447459 return cls (metadata + data , subtype = VECTOR_SUBTYPE )
448460
449461 def as_vector (self ) -> BinaryVector :
450- """**(BETA)** From the Binary, create a list of numbers, along with dtype and padding.
462+ """From the Binary, create a list of numbers, along with dtype and padding.
451463
452464 :return: BinaryVector
453465
0 commit comments