Skip to content

Commit 72571d2

Browse files
committed
post rebase changes
1 parent 2167065 commit 72571d2

5 files changed

Lines changed: 56 additions & 49 deletions

File tree

python/pyarrow-stubs/pyarrow/_stubs_typing.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import numpy as np
2525

2626
from numpy.typing import NDArray
2727

28+
from pyarrow import lib
2829
from pyarrow.lib import BooleanArray, IntegerArray, ChunkedArray
2930

3031
ArrayLike: TypeAlias = Any
@@ -46,7 +47,6 @@ Compression: TypeAlias = Literal[
4647
NullEncoding: TypeAlias = Literal["mask", "encode"]
4748
NullSelectionBehavior: TypeAlias = Literal["drop", "emit_null"]
4849
TimeUnit: TypeAlias = Literal["s", "ms", "us", "ns"]
49-
from pyarrow import lib
5050

5151
IntegerType: TypeAlias = (
5252
lib.Int8Type
@@ -82,23 +82,23 @@ SingleOrList: TypeAlias = list[_T] | _T
8282

8383

8484
class SupportEq(Protocol):
85-
def __eq__(self, other) -> bool: ...
85+
def __eq__(self, other: object) -> bool: ...
8686

8787

8888
class SupportLt(Protocol):
89-
def __lt__(self, other) -> bool: ...
89+
def __lt__(self, other: object) -> bool: ...
9090

9191

9292
class SupportGt(Protocol):
93-
def __gt__(self, other) -> bool: ...
93+
def __gt__(self, other: object) -> bool: ...
9494

9595

9696
class SupportLe(Protocol):
97-
def __le__(self, other) -> bool: ...
97+
def __le__(self, other: object) -> bool: ...
9898

9999

100100
class SupportGe(Protocol):
101-
def __ge__(self, other) -> bool: ...
101+
def __ge__(self, other: object) -> bool: ...
102102

103103

104104
FilterTuple: TypeAlias = (
@@ -140,7 +140,7 @@ class SupportArrowSchema(Protocol):
140140
def __arrow_c_schema__(self) -> Any: ...
141141

142142

143-
class NullableCollection(Protocol[_V]): # type: ignore[reportInvalidTypeVarUse]
143+
class NullableCollection(Protocol[_V]):
144144
def __iter__(self) -> Iterator[_V] | Iterator[_V | None]: ...
145145
def __len__(self) -> int: ...
146146
def __contains__(self, item: Any, /) -> bool: ...

python/pyarrow-stubs/pyarrow/_types.pyi

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,18 @@
1616
# under the License.
1717

1818
import datetime as dt # noqa: F401
19-
import sys
2019

2120
from collections.abc import Mapping, Sequence, Iterable, Iterator
2221
from decimal import Decimal # noqa: F401
23-
24-
if sys.version_info >= (3, 11):
25-
from typing import Self
26-
else:
27-
from typing_extensions import Self
28-
2922
from typing import Any, Generic, Literal
3023

3124
import numpy as np
3225
import pandas as pd
3326

34-
from pyarrow._stubs_typing import SupportArrowSchema
27+
from typing_extensions import Self, TypeVar, deprecated
28+
29+
from pyarrow._stubs_typing import SupportArrowSchema, TimeUnit
30+
from pyarrow.io import Buffer
3531
from pyarrow.lib import ( # noqa: F401
3632
Array,
3733
ChunkedArray,
@@ -40,11 +36,7 @@ from pyarrow.lib import ( # noqa: F401
4036
MonthDayNano,
4137
Table,
4238
)
43-
from typing_extensions import TypeVar, deprecated
44-
45-
from .io import Buffer
46-
from .scalar import ExtensionScalar
47-
from ._stubs_typing import TimeUnit
39+
from pyarrow.scalar import ExtensionScalar
4840

4941
class _Weakrefable:
5042
...
@@ -226,39 +218,44 @@ class DurationType(_BasicDataType[dt.timedelta], Generic[_Unit]):
226218
def unit(self) -> _Unit: ...
227219

228220

229-
class FixedSizeBinaryType(_BasicDataType[Decimal]):
221+
_FixedSizeBinaryAsPyType = TypeVar("_FixedSizeBinaryAsPyType", default=bytes)
222+
223+
224+
class FixedSizeBinaryType(
225+
_BasicDataType[_FixedSizeBinaryAsPyType], Generic[_FixedSizeBinaryAsPyType]
226+
):
230227
...
231228

232229

233230
_Precision = TypeVar("_Precision", default=Any)
234231
_Scale = TypeVar("_Scale", default=Any)
235232

236233

237-
class Decimal32Type(FixedSizeBinaryType, Generic[_Precision, _Scale]):
234+
class Decimal32Type(FixedSizeBinaryType[Decimal], Generic[_Precision, _Scale]):
238235
@property
239236
def precision(self) -> _Precision: ...
240237

241238
@property
242239
def scale(self) -> _Scale: ...
243240

244241

245-
class Decimal64Type(FixedSizeBinaryType, Generic[_Precision, _Scale]):
242+
class Decimal64Type(FixedSizeBinaryType[Decimal], Generic[_Precision, _Scale]):
246243
@property
247244
def precision(self) -> _Precision: ...
248245

249246
@property
250247
def scale(self) -> _Scale: ...
251248

252249

253-
class Decimal128Type(FixedSizeBinaryType, Generic[_Precision, _Scale]):
250+
class Decimal128Type(FixedSizeBinaryType[Decimal], Generic[_Precision, _Scale]):
254251
@property
255252
def precision(self) -> _Precision: ...
256253

257254
@property
258255
def scale(self) -> _Scale: ...
259256

260257

261-
class Decimal256Type(FixedSizeBinaryType, Generic[_Precision, _Scale]):
258+
class Decimal256Type(FixedSizeBinaryType[Decimal], Generic[_Precision, _Scale]):
262259
@property
263260
def precision(self) -> _Precision: ...
264261

@@ -491,7 +488,7 @@ def unregister_extension_type(type_name: str) -> None: ...
491488
class KeyValueMetadata(_Metadata, Mapping[bytes, bytes]):
492489
def __init__(
493490
self, __arg0__: Mapping[str | bytes, str | bytes]
494-
| Iterable[tuple[str, str]]
491+
| Iterable[tuple[str | bytes, str | bytes]]
495492
| KeyValueMetadata
496493
| None = None, **kwargs: str
497494
) -> None: ...
@@ -500,9 +497,9 @@ class KeyValueMetadata(_Metadata, Mapping[bytes, bytes]):
500497

501498
def __len__(self) -> int: ...
502499

503-
def __contains__(self, /, __key: object) -> bool: ... # type: ignore[override]
500+
def __contains__(self, /, __key: object) -> bool: ...
504501

505-
def __getitem__(self, /, __key: Any) -> Any: ... # type: ignore[override]
502+
def __getitem__(self, /, __key: Any) -> Any: ...
506503

507504
def __iter__(self) -> Iterator[bytes]: ...
508505

@@ -636,7 +633,7 @@ def unify_schemas(
636633

637634
def field(
638635
name: SupportArrowSchema | str | Any, type: _DataTypeT | str | None = None,
639-
nullable: bool = ...,
636+
nullable: bool = True,
640637
metadata: dict[Any, Any] | None = None
641638
) -> Field[_DataTypeT] | Field[Any]: ...
642639

@@ -702,20 +699,20 @@ def float32() -> Float32Type: ...
702699
def float64() -> Float64Type: ...
703700

704701

705-
def decimal32(precision: _Precision, scale: _Scale |
706-
None = None) -> Decimal32Type[_Precision, _Scale | Literal[0]]: ...
702+
def decimal32(precision: _Precision,
703+
scale: _Scale | Literal[0] = 0) -> Decimal32Type[_Precision, _Scale | Literal[0]]: ...
707704

708705

709-
def decimal64(precision: _Precision, scale: _Scale |
710-
None = None) -> Decimal64Type[_Precision, _Scale | Literal[0]]: ...
706+
def decimal64(precision: _Precision,
707+
scale: _Scale | Literal[0] = 0) -> Decimal64Type[_Precision, _Scale | Literal[0]]: ...
711708

712709

713-
def decimal128(precision: _Precision, scale: _Scale |
714-
None = None) -> Decimal128Type[_Precision, _Scale | Literal[0]]: ...
710+
def decimal128(precision: _Precision,
711+
scale: _Scale | Literal[0] = 0) -> Decimal128Type[_Precision, _Scale | Literal[0]]: ...
715712

716713

717-
def decimal256(precision: _Precision, scale: _Scale |
718-
None = None) -> Decimal256Type[_Precision, _Scale | Literal[0]]: ...
714+
def decimal256(precision: _Precision,
715+
scale: _Scale | Literal[0] = 0) -> Decimal256Type[_Precision, _Scale | Literal[0]]: ...
719716

720717

721718
def string() -> StringType: ...
@@ -724,7 +721,7 @@ def string() -> StringType: ...
724721
utf8 = string
725722

726723

727-
def binary(length: Literal[-1] | int = ...) -> BinaryType | FixedSizeBinaryType: ...
724+
def binary(length: Literal[-1] | int = ...) -> BinaryType | FixedSizeBinaryType[bytes]: ...
728725

729726

730727
def large_binary() -> LargeBinaryType: ...
@@ -764,8 +761,8 @@ def large_list_view(
764761
def map_(
765762
key_type: _K | Field | str | None = None,
766763
item_type: _ValueT | Field | str | None = None,
767-
keys_sorted: bool | None = None
768-
) -> MapType[_K, _ValueT, Literal[False]]: ...
764+
keys_sorted: _Ordered | None = None
765+
) -> MapType[_K, _ValueT, _Ordered]: ...
769766

770767

771768
def dictionary(

python/pyarrow-stubs/pyarrow/error.pyi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import sys
19-
20-
if sys.version_info >= (3, 11):
21-
from typing import Self
22-
else:
23-
from typing_extensions import Self
18+
from typing_extensions import Self
2419

2520

2621
class ArrowException(Exception):
@@ -80,7 +75,6 @@ have_signal_refcycle: bool
8075
class SignalStopHandler:
8176
def __enter__(self) -> Self: ...
8277
def __exit__(self, exc_type, exc_value, exc_tb) -> None: ...
83-
def __dealloc__(self) -> None: ...
8478
@property
8579
def stop_token(self) -> StopToken: ...
8680

python/pyarrow-stubs/pyarrow/io.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
"""Placeholder stub - complete annotations in future PR."""
18+
"""Placeholder stub - complete annotations in future PR.
19+
20+
At runtime, these symbols are provided by the pyarrow.lib C extension.
21+
"""
1922

2023
from typing import Any
2124

25+
26+
class Buffer:
27+
...
28+
29+
2230
def __getattr__(name: str) -> Any: ...

python/pyarrow-stubs/pyarrow/scalar.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
"""Placeholder stub - complete annotations in future PR."""
18+
"""Placeholder stub - complete annotations in future PR.
19+
20+
At runtime, these symbols are provided by the pyarrow.lib C extension.
21+
"""
1922

2023
from typing import Any
2124

25+
26+
class ExtensionScalar:
27+
...
28+
29+
2230
def __getattr__(name: str) -> Any: ...

0 commit comments

Comments
 (0)