Skip to content

Commit 0ef19f5

Browse files
- added IntoValues type alias
- Using IntoExprColumn on StarExpression - fixed lhs type for LambdaExpression, and value type for ConstantExpression
1 parent bc673d1 commit 0ef19f5

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

_duckdb-stubs/__init__.pyi

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if typing.TYPE_CHECKING:
1212
import pyarrow.lib
1313
from builtins import list as lst
1414
from collections.abc import Callable, Iterable, Sequence, Mapping
15-
from ._typing import ParquetFieldIdsType, IntoExpr, IntoExprColumn, PythonLiteral
15+
from ._typing import ParquetFieldIdsType, IntoExpr, IntoExprColumn, PythonLiteral, IntoValues
1616
from duckdb import sqltypes, func
1717

1818
__all__: lst[str] = [
@@ -458,7 +458,7 @@ class DuckDBPyConnection:
458458
) -> sqltypes.DuckDBPyType: ...
459459
def unregister(self, view_name: str) -> DuckDBPyConnection: ...
460460
def unregister_filesystem(self, name: str) -> None: ...
461-
def values(self, *args: lst[PythonLiteral] | tuple[Expression, ...] | Expression) -> DuckDBPyRelation: ...
461+
def values(self, *args: IntoValues) -> DuckDBPyRelation: ...
462462
def view(self, view_name: str) -> DuckDBPyRelation: ...
463463
@property
464464
def description(self) -> lst[tuple[str, sqltypes.DuckDBPyType, None, None, None, None, None]]: ...
@@ -1009,12 +1009,12 @@ class token_type:
10091009
def CaseExpression(condition: IntoExpr, value: IntoExpr) -> Expression: ...
10101010
def CoalesceOperator(*args: IntoExpr) -> Expression: ...
10111011
def ColumnExpression(*args: str) -> Expression: ...
1012-
def ConstantExpression(value: typing.Any) -> Expression: ...
1012+
def ConstantExpression(value: PythonLiteral) -> Expression: ...
10131013
def DefaultExpression() -> Expression: ...
10141014
def FunctionExpression(function_name: str, *args: IntoExpr) -> Expression: ...
1015-
def LambdaExpression(lhs: typing.Any, rhs: IntoExpr) -> Expression: ...
1015+
def LambdaExpression(lhs: IntoExprColumn | tuple[IntoExprColumn, ...], rhs: IntoExpr) -> Expression: ...
10161016
def SQLExpression(expression: str) -> Expression: ...
1017-
def StarExpression(*, exclude: Iterable[str | Expression] | None = None) -> Expression: ...
1017+
def StarExpression(*, exclude: Iterable[IntoExprColumn] | None = None) -> Expression: ...
10181018
def aggregate(
10191019
df: pandas.DataFrame,
10201020
aggr_expr: str | Iterable[IntoExpr],
@@ -1433,9 +1433,7 @@ def union_type(
14331433
) -> sqltypes.DuckDBPyType: ...
14341434
def unregister(view_name: str, *, connection: DuckDBPyConnection | None = None) -> DuckDBPyConnection: ...
14351435
def unregister_filesystem(name: str, *, connection: DuckDBPyConnection | None = None) -> None: ...
1436-
def values(
1437-
*args: lst[PythonLiteral] | tuple[Expression, ...] | Expression, connection: DuckDBPyConnection | None = None
1438-
) -> DuckDBPyRelation: ...
1436+
def values(*args: IntoValues, connection: DuckDBPyConnection | None = None) -> DuckDBPyRelation: ...
14391437
def view(view_name: str, *, connection: DuckDBPyConnection | None = None) -> DuckDBPyRelation: ...
14401438
def write_csv(
14411439
df: pandas.DataFrame,

_duckdb-stubs/_typing.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ PythonLiteral: TypeAlias = (
5353
"""Python objects that can be converted to a `ConstantExpression`."""
5454
# the field_ids argument to to_parquet and write_parquet has a recursive structure
5555
ParquetFieldIdsType: TypeAlias = Mapping[str, int | ParquetFieldIdsType]
56-
56+
IntoValues: TypeAlias = list[PythonLiteral] | tuple[Expression, ...] | Expression
57+
"""Types that can be converted to a table of values."""
5758
IntoExprColumn: TypeAlias = Expression | str
5859
"""Types that are, or can be used as a `ColumnExpression`."""
5960
IntoExpr: TypeAlias = IntoExprColumn | PythonLiteral

0 commit comments

Comments
 (0)