Skip to content

Commit

Permalink
padding in now Optional[int] = None
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyclements committed Oct 1, 2024
1 parent dfb322c commit 8946daf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bson/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import struct
from dataclasses import dataclass
from enum import Enum
from typing import TYPE_CHECKING, Any, Sequence, Tuple, Type, Union
from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, Type, Union
from uuid import UUID

"""Tools for representing BSON binary data.
Expand Down Expand Up @@ -406,7 +406,7 @@ def from_vector(
cls: Type[Binary],
vector: list[int, float],
dtype: BinaryVectorDtype,
padding: int = 0,
padding: Optional[int] = None,
) -> Binary:
"""**(BETA)** Create a BSON :class:`~bson.binary.Binary` of Vector subtype from a list of Numbers.
Expand All @@ -428,6 +428,7 @@ def from_vector(
raise ValueError(f"padding does not apply to {dtype=}")
elif dtype == BinaryVectorDtype.PACKED_BIT: # pack ints in [0, 255] as unsigned uint8
format_str = "B"
padding = 0 if padding is None else padding
elif dtype == BinaryVectorDtype.FLOAT32: # pack floats as float32
format_str = "f"
if padding:
Expand Down

0 comments on commit 8946daf

Please sign in to comment.