Repository navigation
Closed
Labels
Description
What happens?
Another issue for type check.
According to the documentation, StarExpression accepts a list (not clearly stated though) as its parameter. However, the stub has the signature (line 1021 in _duckdb-stubs/__init__.pyi, the main branch)
def StarExpression(*, exclude: Expression | str | tuple[str]) -> Expression: ...To Reproduce
In example.py:
import duckdb
import pandas as pd
df = pd.DataFrame({
"a": [1, 2, 3, 4],
"b": [True, None, False, True],
"c": [42, 21, 13, 14]
})
star = duckdb.StarExpression(exclude = ['b'])
duckdb.df(df).select(star).show()Then, run any type checker:
❯ uv run ty check example.py
error[invalid-argument-type]: Argument to function `StarExpression` is incorrect
--> example.py:10:30
|
8 | })
9 |
10 | star = duckdb.StarExpression(exclude = ['b'])
| ^^^^^^^^^^^^^^^ Expected `Expression | str | tuple[str]`, found `list[Unknown | str]`
11 | duckdb.df(df).select(star).show()
|
info: Matching overload defined here
--> .venv/lib/python3.13/site-packages/_duckdb-stubs/__init__.pyi:1041:5
|
1039 | def SQLExpression(expression: str) -> Expression: ...
1040 | @pytyping.overload
1041 | def StarExpression(*, exclude: Expression | str | tuple[str]) -> Expression: ...
| ^^^^^^^^^^^^^^ -------------------------------------- Parameter declared here
1042 | @pytyping.overload
1043 | def StarExpression() -> Expression: ...
|
info: Non-matching overloads for function `StarExpression`:
info: () -> Expression
info: rule `invalid-argument-type` is enabled by default
Found 1 diagnosticOS:
aarch64_darwin
DuckDB Package Version:
1.4.2
Python Version:
3.13.9
Full Name:
Mitsuhiro Nacamura
Affiliation:
Nacamura Data Analysis
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration to reproduce the issue?
- Yes, I have
Reacted by Ilia Ablamonov
Activity
OutSquareCapital commentedon Feb 12, 2026
now the type hint is
Any. Type checkers won't complain but it's now useful for type safety, and anyway the documentation is incorrect in the sense that it should say an Iterable rather than a list.Any non-Iterable argument will indeed be rejected.
From my understanding, the correct type should then be
Iterable[str | Expression]See below:
Code
ouput
* EXCLUDE (foo, bar, baz)* EXCLUDE (foo, bar, baz)* EXCLUDE (foo, bar, baz)'int' object is not iterableOnly ColumnExpressions are accepted Expression types here* EXCLUDE (x)* EXCLUDE (foo)'_duckdb.Expression' object is not iterableevertlammerts commentedon Feb 17, 2026
Fixed in #323.
OutSquareCapital commentedon Feb 17, 2026
Same observation as I made in #209, list is too narrow.
Fix multiple stub issues (#323)