xlr8 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,173 @@
1
+ """Type stubs for XLR8 Cursor - provides full IDE autocomplete and type safety.
2
+
3
+ This stub intentionally exposes the full PyMongo Cursor surface area via typing
4
+ inheritance, since XLR8Cursor delegates unsupported methods/attributes to the
5
+ underlying PyMongo cursor at runtime (typically via __getattr__).
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from datetime import date, datetime, timedelta
11
+ from types import TracebackType
12
+ from typing import (
13
+ Any,
14
+ Callable,
15
+ Dict,
16
+ Generator,
17
+ Iterator,
18
+ List,
19
+ Literal,
20
+ Optional,
21
+ Tuple,
22
+ Union,
23
+ )
24
+
25
+ import pandas as pd
26
+ import polars as pl
27
+ import pyarrow as pa
28
+ from pymongo.cursor import Cursor as PyMongoCursor
29
+ from pymongo.cursor import CursorType
30
+
31
+ class XLR8Cursor(PyMongoCursor):
32
+ """PyMongo-compatible cursor with optional acceleration.
33
+
34
+ Notes:
35
+ - This type stub subclasses PyMongoCursor to provide full autocomplete for
36
+ PyMongo cursor methods.
37
+ - At runtime, XLR8Cursor may delegate to an internal PyMongo cursor.
38
+ - For direct access to the underlying PyMongo cursor, use raw_cursor().
39
+ """
40
+
41
+ def __init__(
42
+ self,
43
+ collection: Any,
44
+ query_filter: Dict[str, Any],
45
+ projection: Optional[Dict[str, Any]] = ...,
46
+ skip: int = ...,
47
+ limit: int = ...,
48
+ sort: Optional[List[Tuple[str, int]]] = ...,
49
+ batch_size: int = ...,
50
+ ) -> None: ...
51
+
52
+ # =========================================================================
53
+ # XLR8 Accelerated Methods
54
+ # =========================================================================
55
+
56
+ def to_dataframe(
57
+ self,
58
+ accelerate: bool = ...,
59
+ cache_read: bool = ...,
60
+ cache_write: bool = ...,
61
+ start_date: Optional[Union[datetime, date, str]] = ...,
62
+ end_date: Optional[Union[datetime, date, str]] = ...,
63
+ coerce: Literal["raise", "error"] = ...,
64
+ max_workers: int = ...,
65
+ chunking_granularity: Optional[timedelta] = ...,
66
+ row_group_size: Optional[int] = ...,
67
+ flush_ram_limit_mb: int = ...,
68
+ ) -> "pd.DataFrame": ...
69
+ def to_polars(
70
+ self,
71
+ accelerate: bool = ...,
72
+ cache_read: bool = ...,
73
+ cache_write: bool = ...,
74
+ start_date: Optional[Union[datetime, date, str]] = ...,
75
+ end_date: Optional[Union[datetime, date, str]] = ...,
76
+ coerce: Literal["raise", "error"] = ...,
77
+ max_workers: int = ...,
78
+ chunking_granularity: Optional[timedelta] = ...,
79
+ row_group_size: Optional[int] = ...,
80
+ any_type_strategy: Literal["float", "string", "keep_struct"] = ...,
81
+ flush_ram_limit_mb: int = ...,
82
+ ) -> "pl.DataFrame": ...
83
+ def to_dataframe_batches(
84
+ self,
85
+ batch_size: int = ...,
86
+ cache_read: bool = ...,
87
+ cache_write: bool = ...,
88
+ start_date: Optional[Union[datetime, date, str]] = ...,
89
+ end_date: Optional[Union[datetime, date, str]] = ...,
90
+ coerce: Literal["raise", "error"] = ...,
91
+ max_workers: int = ...,
92
+ chunking_granularity: Optional[timedelta] = ...,
93
+ row_group_size: Optional[int] = ...,
94
+ flush_ram_limit_mb: int = ...,
95
+ ) -> Generator["pd.DataFrame", None, None]: ...
96
+ def stream_to_callback(
97
+ self,
98
+ callback: Callable[["pa.Table", Dict[str, Any]], None],
99
+ *,
100
+ partition_time_delta: timedelta,
101
+ partition_by: Optional[Union[str, List[str]]] = ...,
102
+ any_type_strategy: Literal["float", "string", "keep_struct"] = ...,
103
+ max_workers: int = ...,
104
+ chunking_granularity: Optional[timedelta] = ...,
105
+ row_group_size: Optional[int] = ...,
106
+ flush_ram_limit_mb: int = ...,
107
+ cache_read: bool = ...,
108
+ cache_write: bool = ...,
109
+ ) -> Dict[str, Any]: ...
110
+ def explain_acceleration(self) -> Dict[str, Any]: ...
111
+ def raw_cursor(self) -> PyMongoCursor: ...
112
+
113
+ # =========================================================================
114
+ # Delegation escape hatch
115
+ # =========================================================================
116
+
117
+ def __getattr__(self, name: str) -> Any: ...
118
+ def __iter__(self) -> Iterator[Dict[str, Any]]: ...
119
+ def __next__(self) -> Dict[str, Any]: ...
120
+ def __enter__(self) -> "XLR8Cursor": ...
121
+ def __exit__(
122
+ self,
123
+ exc_type: Optional[type],
124
+ exc_val: Optional[BaseException],
125
+ exc_tb: Optional[TracebackType],
126
+ ) -> None: ...
127
+
128
+ # =========================================================================
129
+ # Common PyMongo Cursor API (typed overrides for chaining)
130
+ # =========================================================================
131
+
132
+ def next(self) -> Dict[str, Any]: ...
133
+ def clone(self) -> "XLR8Cursor": ...
134
+ def rewind(self) -> "XLR8Cursor": ...
135
+ def close(self) -> None: ...
136
+ @property
137
+ def alive(self) -> bool: ...
138
+ @property
139
+ def cursor_id(self) -> Optional[int]: ...
140
+ @property
141
+ def address(self) -> Optional[Tuple[str, int]]: ...
142
+ @property
143
+ def session(self) -> Optional[Any]: ...
144
+
145
+ # Cursor modifiers (return self for chaining)
146
+ def add_option(self, mask: int) -> "XLR8Cursor": ...
147
+ def remove_option(self, mask: int) -> "XLR8Cursor": ...
148
+ def allow_disk_use(self, allow: bool = ...) -> "XLR8Cursor": ...
149
+ def batch_size(self, batch_size: int) -> "XLR8Cursor": ...
150
+ def collation(self, collation: Dict[str, Any]) -> "XLR8Cursor": ...
151
+ def comment(self, comment: str) -> "XLR8Cursor": ...
152
+ def hint(self, index: Union[str, List[Tuple[str, int]]]) -> "XLR8Cursor": ...
153
+ def limit(self, limit: int) -> "XLR8Cursor": ...
154
+ def max(self, spec: List[Tuple[str, Any]]) -> "XLR8Cursor": ...
155
+ def max_await_time_ms(self, max_await_time_ms: int) -> "XLR8Cursor": ...
156
+ def max_scan(self, max_scan: int) -> "XLR8Cursor": ...
157
+ def max_time_ms(self, max_time_ms: int) -> "XLR8Cursor": ...
158
+ def min(self, spec: List[Tuple[str, Any]]) -> "XLR8Cursor": ...
159
+ def skip(self, skip: int) -> "XLR8Cursor": ...
160
+ def sort(
161
+ self,
162
+ key_or_list: Union[str, List[Tuple[str, int]]],
163
+ direction: Optional[int] = ...,
164
+ ) -> "XLR8Cursor": ...
165
+ def where(self, code: str) -> "XLR8Cursor": ...
166
+
167
+ # CursorType helpers
168
+ def cursor_type(self, cursor_type: CursorType) -> "XLR8Cursor": ...
169
+
170
+ # Query execution
171
+ def count(self, with_limit_and_skip: bool = ...) -> int: ...
172
+ def distinct(self, key: str) -> List[Any]: ...
173
+ def explain(self) -> Dict[str, Any]: ...