Skip to content

Commit 0e0efcc

Browse files
committed
Removes __init__ and attempts to add default padding via field
1 parent c9a85ad commit 0e0efcc

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

bson/binary.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from __future__ import annotations
1515

1616
import struct
17-
from dataclasses import dataclass
17+
from dataclasses import dataclass, field
1818
from enum import Enum
1919
from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, Type, Union, overload
2020
from uuid import UUID
@@ -231,21 +231,20 @@ class BinaryVectorDtype(Enum):
231231
class BinaryVector:
232232
"""Vector of numbers along with metadata for binary interoperability.
233233
.. versionadded:: 4.10
234+
235+
:param data: Sequence of numbers representing the mathematical vector.
236+
:param dtype: The data type stored in binary
237+
:param padding: The number of bits in the final byte that are to be ignored
238+
when a vector element's size is less than a byte
239+
and the length of the vector is not a multiple of 8.
240+
Defaults to 0.
234241
"""
235242

236243
__slots__ = ("data", "dtype", "padding")
237244

238-
def __init__(self, data: Sequence[float | int], dtype: BinaryVectorDtype, padding: int = 0):
239-
"""
240-
:param data: Sequence of numbers representing the mathematical vector.
241-
:param dtype: The data type stored in binary
242-
:param padding: The number of bits in the final byte that are to be ignored
243-
when a vector element's size is less than a byte
244-
and the length of the vector is not a multiple of 8.
245-
"""
246-
self.data = data
247-
self.dtype = dtype
248-
self.padding = padding
245+
data: Sequence[float | int]
246+
dtype: BinaryVectorDtype
247+
padding: int = field(default=0)
249248

250249

251250
class Binary(bytes):

0 commit comments

Comments
 (0)