Skip to content

Commit cdf800e

Browse files
Fix multiple stub issues (#323)
Fix type stubs for 7 issues: - #131 - #194 - #209 - #210 - #260 - #279 - #314
2 parents 7f45e6f + 78114e0 commit cdf800e

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

_duckdb-stubs/__init__.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ if pytyping.TYPE_CHECKING:
99
import polars
1010
import pandas
1111
import pyarrow.lib
12-
import torch as pytorch
13-
import tensorflow
1412
from collections.abc import Callable, Sequence, Mapping
1513
from duckdb import sqltypes, func
1614

@@ -247,7 +245,7 @@ class DuckDBPyConnection:
247245
def from_arrow(self, arrow_object: object) -> DuckDBPyRelation: ...
248246
def from_csv_auto(
249247
self,
250-
path_or_buffer: str | bytes | os.PathLike[str] | os.PathLike[bytes],
248+
path_or_buffer: str | bytes | os.PathLike[str] | os.PathLike[bytes] | pytyping.IO[bytes],
251249
header: bool | int | None = None,
252250
compression: str | None = None,
253251
sep: str | None = None,
@@ -350,7 +348,7 @@ class DuckDBPyConnection:
350348
def query_progress(self) -> float: ...
351349
def read_csv(
352350
self,
353-
path_or_buffer: str | bytes | os.PathLike[str],
351+
path_or_buffer: str | bytes | os.PathLike[str] | os.PathLike[bytes] | pytyping.IO[bytes],
354352
header: bool | int | None = None,
355353
compression: str | None = None,
356354
sep: str | None = None,
@@ -456,8 +454,8 @@ class DuckDBPyConnection:
456454
) -> sqltypes.DuckDBPyType: ...
457455
def table(self, table_name: str) -> DuckDBPyRelation: ...
458456
def table_function(self, name: str, parameters: object = None) -> DuckDBPyRelation: ...
459-
def tf(self) -> dict[str, tensorflow.Tensor]: ...
460-
def torch(self) -> dict[str, pytorch.Tensor]: ...
457+
def tf(self) -> dict[str, pytyping.Any]: ...
458+
def torch(self) -> dict[str, pytyping.Any]: ...
461459
def type(self, type_str: str) -> sqltypes.DuckDBPyType: ...
462460
def union_type(
463461
self, members: list[sqltypes.DuckDBPyType] | dict[str, sqltypes.DuckDBPyType]
@@ -478,7 +476,7 @@ class DuckDBPyRelation:
478476
def __getitem__(self, name: str) -> DuckDBPyRelation: ...
479477
def __len__(self) -> int: ...
480478
def aggregate(
481-
self, aggr_expr: Expression | str | list[Expression], group_expr: Expression | str = ""
479+
self, aggr_expr: str | Expression | list[Expression | str], group_expr: Expression | str = ""
482480
) -> DuckDBPyRelation: ...
483481
def any_value(
484482
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
@@ -710,7 +708,7 @@ class DuckDBPyRelation:
710708
def sum(
711709
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
712710
) -> DuckDBPyRelation: ...
713-
def tf(self) -> dict[str, tensorflow.Tensor]: ...
711+
def tf(self) -> dict[str, pytyping.Any]: ...
714712
def to_csv(
715713
self,
716714
file_name: str,
@@ -751,7 +749,7 @@ class DuckDBPyRelation:
751749
) -> None: ...
752750
def to_table(self, table_name: str) -> None: ...
753751
def to_view(self, view_name: str, replace: bool = True) -> DuckDBPyRelation: ...
754-
def torch(self) -> dict[str, pytorch.Tensor]: ...
752+
def torch(self) -> dict[str, pytyping.Any]: ...
755753
def union(self, union_rel: DuckDBPyRelation) -> DuckDBPyRelation: ...
756754
def unique(self, unique_aggr: str) -> DuckDBPyRelation: ...
757755
def update(self, set: Expression | str, *, condition: Expression | str | None = None) -> None: ...
@@ -771,6 +769,7 @@ class DuckDBPyRelation:
771769
def write_csv(
772770
self,
773771
file_name: str,
772+
*,
774773
sep: str | None = None,
775774
na_rep: str | None = None,
776775
header: bool | None = None,
@@ -790,6 +789,7 @@ class DuckDBPyRelation:
790789
def write_parquet(
791790
self,
792791
file_name: str,
792+
*,
793793
compression: str | None = None,
794794
field_ids: ParquetFieldIdsType | pytyping.Literal["auto"] | None = None,
795795
row_group_size_bytes: str | int | None = None,
@@ -810,7 +810,7 @@ class DuckDBPyRelation:
810810
@property
811811
def description(self) -> pytyping.List[tuple[str, sqltypes.DuckDBPyType, None, None, None, None, None]]: ...
812812
@property
813-
def dtypes(self) -> pytyping.List[str]: ...
813+
def dtypes(self) -> pytyping.List[sqltypes.DuckDBPyType]: ...
814814
@property
815815
def shape(self) -> tuple[int, int]: ...
816816
@property
@@ -1067,7 +1067,7 @@ def DefaultExpression() -> Expression: ...
10671067
def FunctionExpression(function_name: str, *args: Expression) -> Expression: ...
10681068
def LambdaExpression(lhs: pytyping.Any, rhs: Expression) -> Expression: ...
10691069
def SQLExpression(expression: str) -> Expression: ...
1070-
def StarExpression(*, exclude: pytyping.Any = None) -> Expression: ...
1070+
def StarExpression(*, exclude: list[str | Expression] | None = None) -> Expression: ...
10711071
def aggregate(
10721072
df: pandas.DataFrame,
10731073
aggr_expr: Expression | list[Expression] | str | list[str],
@@ -1194,7 +1194,7 @@ def from_arrow(
11941194
connection: DuckDBPyConnection | None = None,
11951195
) -> DuckDBPyRelation: ...
11961196
def from_csv_auto(
1197-
path_or_buffer: str | bytes | os.PathLike[str],
1197+
path_or_buffer: str | bytes | os.PathLike[str] | os.PathLike[bytes] | pytyping.IO[bytes],
11981198
header: bool | int | None = None,
11991199
compression: str | None = None,
12001200
sep: str | None = None,
@@ -1346,7 +1346,7 @@ def query_df(
13461346
) -> DuckDBPyRelation: ...
13471347
def query_progress(*, connection: DuckDBPyConnection | None = None) -> float: ...
13481348
def read_csv(
1349-
path_or_buffer: str | bytes | os.PathLike[str],
1349+
path_or_buffer: str | bytes | os.PathLike[str] | os.PathLike[bytes] | pytyping.IO[bytes],
13501350
header: bool | int | None = None,
13511351
compression: str | None = None,
13521352
sep: str | None = None,
@@ -1475,9 +1475,9 @@ def table_function(
14751475
*,
14761476
connection: DuckDBPyConnection | None = None,
14771477
) -> DuckDBPyRelation: ...
1478-
def tf(*, connection: DuckDBPyConnection | None = None) -> dict[str, tensorflow.Tensor]: ...
1478+
def tf(*, connection: DuckDBPyConnection | None = None) -> dict[str, pytyping.Any]: ...
14791479
def tokenize(query: str) -> list[tuple[int, token_type]]: ...
1480-
def torch(*, connection: DuckDBPyConnection | None = None) -> dict[str, pytorch.Tensor]: ...
1480+
def torch(*, connection: DuckDBPyConnection | None = None) -> dict[str, pytyping.Any]: ...
14811481
def type(type_str: str, *, connection: DuckDBPyConnection | None = None) -> sqltypes.DuckDBPyType: ...
14821482
def union_type(
14831483
members: dict[str, sqltypes.DuckDBPyType] | list[sqltypes.DuckDBPyType],

_duckdb-stubs/_sqltypes.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class DuckDBPyType:
4343
@pytyping.overload
4444
def __init__(self, obj: object) -> None: ...
4545
@property
46-
def children(self) -> list[tuple[str, object]]: ...
46+
def children(self) -> list[tuple[str, DuckDBPyType | int | list[str]]]: ...
4747
@property
4848
def id(self) -> str: ...
4949

0 commit comments

Comments
 (0)