Skip to content

Commit 7cc57ab

Browse files
committed
ruff
Signed-off-by: Baris Palaska <barispalaska@gmail.com>
1 parent b2aa0ed commit 7cc57ab

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

vortex-python/test/test_arrow_extension.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
from __future__ import annotations
77

88
import base64
9+
from typing import final
910

1011
import pyarrow as pa
12+
from typing_extensions import override
1113

1214
import vortex as vx
1315

@@ -16,20 +18,29 @@
1618
_TIMESTAMP_US_METADATA = bytes([1, 0, 0])
1719

1820

21+
@final
1922
class VortexTimestampType(pa.ExtensionType):
2023
"""pyarrow `ExtensionType` matching Vortex's `vortex.timestamp`."""
2124

25+
_unit: str
26+
2227
def __init__(self, unit: str = "us"):
2328
# pyarrow calls `__arrow_ext_serialize__` from __init__, so `_unit` must be set first.
2429
self._unit = unit
2530
pa.ExtensionType.__init__(self, pa.int64(), "vortex.timestamp")
2631

32+
@override
2733
def __arrow_ext_serialize__(self) -> bytes:
2834
unit_tag = {"ns": 0, "us": 1, "ms": 2, "s": 3}[self._unit]
2935
return bytes([unit_tag, 0, 0])
3036

3137
@classmethod
32-
def __arrow_ext_deserialize__(cls, storage_type, serialized): # noqa: ARG003
38+
@override
39+
def __arrow_ext_deserialize__(
40+
cls,
41+
storage_type: pa.DataType, # noqa: ARG003
42+
serialized: bytes,
43+
) -> VortexTimestampType:
3344
unit_tag = serialized[0]
3445
unit = {0: "ns", 1: "us", 2: "ms", 3: "s"}[unit_tag]
3546
return cls(unit)
@@ -38,7 +49,9 @@ def __arrow_ext_deserialize__(cls, storage_type, serialized): # noqa: ARG003
3849
def test_chunked_extension_array_uses_session_for_leaf_extension_type():
3950
ext_type = VortexTimestampType()
4051
storage = pa.array([1, 2, 3], type=pa.int64())
41-
arrow = pa.chunked_array([pa.ExtensionArray.from_storage(ext_type, storage)])
52+
arrow = pa.chunked_array(
53+
[pa.ExtensionArray.from_storage(ext_type, storage)] # pyright: ignore[reportUnknownMemberType, reportUnknownArgumentType]
54+
)
4255
array = vx.array(arrow)
4356
assert isinstance(array, vx.ChunkedArray)
4457
assert repr(array.dtype) == repr(vx.timestamp("us"))

0 commit comments

Comments
 (0)