Skip to content

Commit 10e0ef3

Browse files
committed
Add explicit polars overloads
1 parent f3b8c8a commit 10e0ef3

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

_duckdb-stubs/__init__.pyi

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,18 @@ class DuckDBPyConnection:
318318
def list_type(self, type: sqltypes.DuckDBPyType) -> sqltypes.DuckDBPyType: ...
319319
def load_extension(self, extension: str) -> None: ...
320320
def map_type(self, key: sqltypes.DuckDBPyType, value: sqltypes.DuckDBPyType) -> sqltypes.DuckDBPyType: ...
321-
def pl(self, rows_per_batch: pytyping.SupportsInt = 1000000, *, lazy: bool = False) -> polars.DataFrame: ...
321+
@pytyping.overload
322+
def pl(
323+
self, rows_per_batch: pytyping.SupportsInt = 1000000, *, lazy: pytyping.Literal[False] = ...
324+
) -> polars.DataFrame: ...
325+
@pytyping.overload
326+
def pl(
327+
self, rows_per_batch: pytyping.SupportsInt = 1000000, *, lazy: pytyping.Literal[True]
328+
) -> polars.LazyFrame: ...
329+
@pytyping.overload
330+
def pl(
331+
self, rows_per_batch: pytyping.SupportsInt = 1000000, *, lazy: bool = False
332+
) -> pytyping.Union[polars.DataFrame, polars.LazyFrame]: ...
322333
def query(self, query: str, *, alias: str = "", params: object = None) -> DuckDBPyRelation: ...
323334
def query_progress(self) -> float: ...
324335
def read_csv(
@@ -596,7 +607,16 @@ class DuckDBPyRelation:
596607
) -> DuckDBPyRelation: ...
597608
def order(self, order_expr: str) -> DuckDBPyRelation: ...
598609
def percent_rank(self, window_spec: str, projected_columns: str = "") -> DuckDBPyRelation: ...
599-
def pl(self, batch_size: pytyping.SupportsInt = 1000000, *, lazy: bool = False) -> polars.DataFrame: ...
610+
@pytyping.overload
611+
def pl(
612+
self, batch_size: pytyping.SupportsInt = 1000000, *, lazy: pytyping.Literal[False] = ...
613+
) -> polars.DataFrame: ...
614+
@pytyping.overload
615+
def pl(self, batch_size: pytyping.SupportsInt = 1000000, *, lazy: pytyping.Literal[True]) -> polars.LazyFrame: ...
616+
@pytyping.overload
617+
def pl(
618+
self, batch_size: pytyping.SupportsInt = 1000000, *, lazy: bool = False
619+
) -> pytyping.Union[polars.DataFrame, polars.LazyFrame]: ...
600620
def product(
601621
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
602622
) -> DuckDBPyRelation: ...
@@ -1241,12 +1261,27 @@ def map_type(
12411261
def order(
12421262
df: pandas.DataFrame, order_expr: str, *, connection: DuckDBPyConnection | None = None
12431263
) -> DuckDBPyRelation: ...
1264+
@pytyping.overload
12441265
def pl(
12451266
rows_per_batch: pytyping.SupportsInt = 1000000,
12461267
*,
1247-
lazy: bool = False,
1268+
lazy: pytyping.Literal[False] = ...,
12481269
connection: DuckDBPyConnection | None = None,
12491270
) -> polars.DataFrame: ...
1271+
@pytyping.overload
1272+
def pl(
1273+
rows_per_batch: pytyping.SupportsInt = 1000000,
1274+
*,
1275+
lazy: pytyping.Literal[True],
1276+
connection: DuckDBPyConnection | None = None,
1277+
) -> polars.LazyFrame: ...
1278+
@pytyping.overload
1279+
def pl(
1280+
rows_per_batch: pytyping.SupportsInt = 1000000,
1281+
*,
1282+
lazy: bool = False,
1283+
connection: DuckDBPyConnection | None = None,
1284+
) -> pytyping.Union[polars.DataFrame, polars.LazyFrame]: ...
12501285
def project(
12511286
df: pandas.DataFrame, *args: str | Expression, groups: str = "", connection: DuckDBPyConnection | None = None
12521287
) -> DuckDBPyRelation: ...

0 commit comments

Comments
 (0)