Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
93753ef
sync upstream
OutSquareCapital Mar 1, 2026
7d1d912
- new _typing and _expression stub file to centralize type aliases an…
OutSquareCapital Feb 26, 2026
40b10d4
refactor of init in consequence of last commit:
OutSquareCapital Feb 26, 2026
03f915e
added Numpy Array protocol to accepted literal types. allow to add nu…
OutSquareCapital Feb 26, 2026
33e9fd8
sync lst builtin fix with 3.10 branch
OutSquareCapital Feb 26, 2026
4348df8
fix: dict keys can't be nested literals
OutSquareCapital Feb 26, 2026
630593f
Relation.update set argument can accept a mapping
OutSquareCapital Feb 26, 2026
bc673d1
values function and Connection method can accept list of Python Liter…
OutSquareCapital Feb 26, 2026
0ef19f5
- added IntoValues type alias
OutSquareCapital Feb 26, 2026
2fba63d
refactor of datatypes typing:
OutSquareCapital Feb 26, 2026
fac91ba
using PythonLiteral types in place of typing.Any for Connexion.create…
OutSquareCapital Feb 27, 2026
8edf762
numpy protocols improvements
OutSquareCapital Feb 27, 2026
d96a4cc
refactor:
OutSquareCapital Feb 27, 2026
4cecd4e
feat:
OutSquareCapital Feb 27, 2026
edbdcf4
feat:
OutSquareCapital Feb 27, 2026
abf1a44
fixs:
OutSquareCapital Mar 1, 2026
2d541b9
lint fixes + fixed missing TypeAlias markers
OutSquareCapital Mar 1, 2026
cbd0efd
bugfix/refactor:
OutSquareCapital Mar 3, 2026
ec22557
Typing : added ParquetCompression and ProfilerFormat literals
OutSquareCapital Mar 3, 2026
b129f72
raw NPArray can be used for value conversions
OutSquareCapital Mar 4, 2026
d6b5852
fix: time_ns and variant dtypes were missing from builtins literal
OutSquareCapital Mar 9, 2026
1104da0
- new _typing and _expression stub file to centralize type aliases an…
OutSquareCapital Feb 26, 2026
1758a30
refactor of init in consequence of last commit:
OutSquareCapital Feb 26, 2026
091e2fc
added Numpy Array protocol to accepted literal types. allow to add nu…
OutSquareCapital Feb 26, 2026
264d5ee
sync lst builtin fix with 3.10 branch
OutSquareCapital Feb 26, 2026
8cc8cdc
fix: dict keys can't be nested literals
OutSquareCapital Feb 26, 2026
aa094dd
Relation.update set argument can accept a mapping
OutSquareCapital Feb 26, 2026
0691938
values function and Connection method can accept list of Python Liter…
OutSquareCapital Feb 26, 2026
542b3a7
- added IntoValues type alias
OutSquareCapital Feb 26, 2026
03700d1
refactor of datatypes typing:
OutSquareCapital Feb 26, 2026
4e21538
using PythonLiteral types in place of typing.Any for Connexion.create…
OutSquareCapital Feb 27, 2026
80b1e81
numpy protocols improvements
OutSquareCapital Feb 27, 2026
3dca9e3
refactor:
OutSquareCapital Feb 27, 2026
e5823f2
feat:
OutSquareCapital Feb 27, 2026
172bc72
feat:
OutSquareCapital Feb 27, 2026
ecf163a
fixs:
OutSquareCapital Mar 1, 2026
af1e4b0
lint fixes + fixed missing TypeAlias markers
OutSquareCapital Mar 1, 2026
b9845d4
bugfix/refactor:
OutSquareCapital Mar 3, 2026
cecd35f
Typing : added ParquetCompression and ProfilerFormat literals
OutSquareCapital Mar 3, 2026
4a50b6f
raw NPArray can be used for value conversions
OutSquareCapital Mar 4, 2026
645458e
fix: time_ns and variant dtypes were missing from builtins literal
OutSquareCapital Mar 9, 2026
82b77fb
Merge branch 'expr-typing' of https://github.com/OutSquareCapital/duc…
OutSquareCapital Mar 30, 2026
4861a82
update submodule
OutSquareCapital Mar 30, 2026
9b05045
bump submodule
OutSquareCapital Mar 30, 2026
3742357
Merge branch 'v1.5-variegata' into expr-typing
OutSquareCapital Mar 30, 2026
e397c5c
Merge remote-tracking branch 'origin/v1.5-variegata' into expr-typing
OutSquareCapital Mar 30, 2026
05b5bcf
fixed various issues after PR review
OutSquareCapital Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
551 changes: 169 additions & 382 deletions _duckdb-stubs/__init__.pyi

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions _duckdb-stubs/_enums.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
from typing import ClassVar, Protocol, SupportsInt, Literal, TypeAlias

class CppEnum(Protocol):
"""Base Enum-like Protocol class in C++ code.

Correspond to `py::enum_` in Pybind11.

Note:
This is marked as a `Protocol` to specify that an `isinstance` check against this class won't work, as this is a typing-only construct.
"""
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: SupportsInt) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __setstate__(self, state: SupportsInt) -> None: ...
@property
def name(self) -> str: ...
@property
def value(self) -> int: ...

class CSVLineTerminator(CppEnum):
CARRIAGE_RETURN_LINE_FEED: ClassVar[CSVLineTerminator] # value = <CSVLineTerminator.CARRIAGE_RETURN_LINE_FEED: 1>
LINE_FEED: ClassVar[CSVLineTerminator] # value = <CSVLineTerminator.LINE_FEED: 0>
__members__: ClassVar[
dict[str, CSVLineTerminator]
] # value = {'LINE_FEED': <CSVLineTerminator.LINE_FEED: 0>, 'CARRIAGE_RETURN_LINE_FEED': <CSVLineTerminator.CARRIAGE_RETURN_LINE_FEED: 1>} # noqa: E501

class ExpectedResultType(CppEnum):
CHANGED_ROWS: ClassVar[ExpectedResultType] # value = <ExpectedResultType.CHANGED_ROWS: 1>
NOTHING: ClassVar[ExpectedResultType] # value = <ExpectedResultType.NOTHING: 2>
QUERY_RESULT: ClassVar[ExpectedResultType] # value = <ExpectedResultType.QUERY_RESULT: 0>
__members__: ClassVar[
dict[str, ExpectedResultType]
] # value = {'QUERY_RESULT': <ExpectedResultType.QUERY_RESULT: 0>, 'CHANGED_ROWS': <ExpectedResultType.CHANGED_ROWS: 1>, 'NOTHING': <ExpectedResultType.NOTHING: 2>} # noqa: E501

class ExplainType(CppEnum):
ANALYZE: ClassVar[ExplainType] # value = <ExplainType.ANALYZE: 1>
STANDARD: ClassVar[ExplainType] # value = <ExplainType.STANDARD: 0>
__members__: ClassVar[
dict[str, ExplainType]
] # value = {'STANDARD': <ExplainType.STANDARD: 0>, 'ANALYZE': <ExplainType.ANALYZE: 1>}

ExplainTypeLiteral: TypeAlias = Literal["analyze", "standard", "ANALYZE", "STANDARD"]

class PythonExceptionHandling(CppEnum):
DEFAULT: ClassVar[PythonExceptionHandling] # value = <PythonExceptionHandling.DEFAULT: 0>
RETURN_NULL: ClassVar[PythonExceptionHandling] # value = <PythonExceptionHandling.RETURN_NULL: 1>
__members__: ClassVar[
dict[str, PythonExceptionHandling]
] # value = {'DEFAULT': <PythonExceptionHandling.DEFAULT: 0>, 'RETURN_NULL': <PythonExceptionHandling.RETURN_NULL: 1>} # noqa: E501

class RenderMode(CppEnum):
COLUMNS: ClassVar[RenderMode] # value = <RenderMode.COLUMNS: 1>
ROWS: ClassVar[RenderMode] # value = <RenderMode.ROWS: 0>
__members__: ClassVar[
dict[str, RenderMode]
] # value = {'ROWS': <RenderMode.ROWS: 0>, 'COLUMNS': <RenderMode.COLUMNS: 1>}

RenderModeLiteral: TypeAlias = Literal["columns", "rows", "COLUMNS", "ROWS"]

class StatementType(CppEnum):
ALTER: ClassVar[StatementType] # value = <StatementType.ALTER: 8>
ANALYZE: ClassVar[StatementType] # value = <StatementType.ANALYZE: 11>
ATTACH: ClassVar[StatementType] # value = <StatementType.ATTACH: 25>
CALL: ClassVar[StatementType] # value = <StatementType.CALL: 19>
COPY_DATABASE: ClassVar[StatementType] # value = <StatementType.COPY_DATABASE: 28>
COPY: ClassVar[StatementType] # value = <StatementType.COPY: 10>
CREATE_FUNC: ClassVar[StatementType] # value = <StatementType.CREATE_FUNC: 13>
CREATE: ClassVar[StatementType] # value = <StatementType.CREATE: 4>
DELETE: ClassVar[StatementType] # value = <StatementType.DELETE: 5>
DETACH: ClassVar[StatementType] # value = <StatementType.DETACH: 26>
DROP: ClassVar[StatementType] # value = <StatementType.DROP: 15>
EXECUTE: ClassVar[StatementType] # value = <StatementType.EXECUTE: 7>
EXPLAIN: ClassVar[StatementType] # value = <StatementType.EXPLAIN: 14>
EXPORT: ClassVar[StatementType] # value = <StatementType.EXPORT: 16>
EXTENSION: ClassVar[StatementType] # value = <StatementType.EXTENSION: 23>
INSERT: ClassVar[StatementType] # value = <StatementType.INSERT: 2>
INVALID: ClassVar[StatementType] # value = <StatementType.INVALID: 0>
LOAD: ClassVar[StatementType] # value = <StatementType.LOAD: 21>
LOGICAL_PLAN: ClassVar[StatementType] # value = <StatementType.LOGICAL_PLAN: 24>
MERGE_INTO: ClassVar[StatementType] # value = <StatementType.MERGE_INTO: 30>
MULTI: ClassVar[StatementType] # value = <StatementType.MULTI: 27>
PRAGMA: ClassVar[StatementType] # value = <StatementType.PRAGMA: 17>
PREPARE: ClassVar[StatementType] # value = <StatementType.PREPARE: 6>
RELATION: ClassVar[StatementType] # value = <StatementType.RELATION: 22>
SELECT: ClassVar[StatementType] # value = <StatementType.SELECT: 1>
SET: ClassVar[StatementType] # value = <StatementType.SET: 20>
TRANSACTION: ClassVar[StatementType] # value = <StatementType.TRANSACTION: 9>
UPDATE: ClassVar[StatementType] # value = <StatementType.UPDATE: 3>
VACUUM: ClassVar[StatementType] # value = <StatementType.VACUUM: 18>
VARIABLE_SET: ClassVar[StatementType] # value = <StatementType.VARIABLE_SET: 12>
__members__: ClassVar[
dict[str, StatementType]
] # value = {'INVALID': <StatementType.INVALID: 0>, 'SELECT': <StatementType.SELECT: 1>, 'INSERT': <StatementType.INSERT: 2>, 'UPDATE': <StatementType.UPDATE: 3>, 'CREATE': <StatementType.CREATE: 4>, 'DELETE': <StatementType.DELETE: 5>, 'PREPARE': <StatementType.PREPARE: 6>, 'EXECUTE': <StatementType.EXECUTE: 7>, 'ALTER': <StatementType.ALTER: 8>, 'TRANSACTION': <StatementType.TRANSACTION: 9>, 'COPY': <StatementType.COPY: 10>, 'ANALYZE': <StatementType.ANALYZE: 11>, 'VARIABLE_SET': <StatementType.VARIABLE_SET: 12>, 'CREATE_FUNC': <StatementType.CREATE_FUNC: 13>, 'EXPLAIN': <StatementType.EXPLAIN: 14>, 'DROP': <StatementType.DROP: 15>, 'EXPORT': <StatementType.EXPORT: 16>, 'PRAGMA': <StatementType.PRAGMA: 17>, 'VACUUM': <StatementType.VACUUM: 18>, 'CALL': <StatementType.CALL: 19>, 'SET': <StatementType.SET: 20>, 'LOAD': <StatementType.LOAD: 21>, 'RELATION': <StatementType.RELATION: 22>, 'EXTENSION': <StatementType.EXTENSION: 23>, 'LOGICAL_PLAN': <StatementType.LOGICAL_PLAN: 24>, 'ATTACH': <StatementType.ATTACH: 25>, 'DETACH': <StatementType.DETACH: 26>, 'MULTI': <StatementType.MULTI: 27>, 'COPY_DATABASE': <StatementType.COPY_DATABASE: 28>, 'MERGE_INTO': <StatementType.MERGE_INTO: 30>} # noqa: E501

class token_type(CppEnum):
__members__: ClassVar[
dict[str, token_type]
] # value = {'identifier': <token_type.identifier: 0>, 'numeric_const': <token_type.numeric_const: 1>, 'string_const': <token_type.string_const: 2>, 'operator': <token_type.operator: 3>, 'keyword': <token_type.keyword: 4>, 'comment': <token_type.comment: 5>} # noqa: E501
comment: ClassVar[token_type] # value = <token_type.comment: 5>
identifier: ClassVar[token_type] # value = <token_type.identifier: 0>
keyword: ClassVar[token_type] # value = <token_type.keyword: 4>
numeric_const: ClassVar[token_type] # value = <token_type.numeric_const: 1>
operator: ClassVar[token_type] # value = <token_type.operator: 3>
string_const: ClassVar[token_type] # value = <token_type.string_const: 2>
54 changes: 54 additions & 0 deletions _duckdb-stubs/_expression.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from typing import TYPE_CHECKING, Any, overload

if TYPE_CHECKING:
from ._typing import IntoExpr, IntoPyType

class Expression:
def __add__(self, other: IntoExpr) -> Expression: ...
def __and__(self, other: IntoExpr) -> Expression: ...
def __div__(self, other: IntoExpr) -> Expression: ...
def __eq__(self, other: IntoExpr) -> Expression: ... # type: ignore[override]
def __floordiv__(self, other: IntoExpr) -> Expression: ...
def __ge__(self, other: IntoExpr) -> Expression: ...
def __gt__(self, other: IntoExpr) -> Expression: ...
@overload
def __init__(self, arg0: str) -> None: ...
@overload
def __init__(self, arg0: Any) -> None: ...
def __invert__(self) -> Expression: ...
def __le__(self, other: IntoExpr) -> Expression: ...
def __lt__(self, other: IntoExpr) -> Expression: ...
def __mod__(self, other: IntoExpr) -> Expression: ...
def __mul__(self, other: IntoExpr) -> Expression: ...
def __ne__(self, other: IntoExpr) -> Expression: ... # type: ignore[override]
def __neg__(self) -> Expression: ...
def __or__(self, other: IntoExpr) -> Expression: ...
def __pow__(self, other: IntoExpr) -> Expression: ...
def __radd__(self, other: IntoExpr) -> Expression: ...
def __rand__(self, other: IntoExpr) -> Expression: ...
def __rdiv__(self, other: IntoExpr) -> Expression: ...
def __rfloordiv__(self, other: IntoExpr) -> Expression: ...
def __rmod__(self, other: IntoExpr) -> Expression: ...
def __rmul__(self, other: IntoExpr) -> Expression: ...
def __ror__(self, other: IntoExpr) -> Expression: ...
def __rpow__(self, other: IntoExpr) -> Expression: ...
def __rsub__(self, other: IntoExpr) -> Expression: ...
def __rtruediv__(self, other: IntoExpr) -> Expression: ...
def __sub__(self, other: IntoExpr) -> Expression: ...
def __truediv__(self, other: IntoExpr) -> Expression: ...
def alias(self, name: str) -> Expression: ...
def asc(self) -> Expression: ...
def between(self, lower: IntoExpr, upper: IntoExpr) -> Expression: ...
def cast(self, type: IntoPyType) -> Expression: ...
def collate(self, collation: str) -> Expression: ...
def desc(self) -> Expression: ...
def get_name(self) -> str: ...
def isin(self, *args: IntoExpr) -> Expression: ...
def isnotin(self, *args: IntoExpr) -> Expression: ...
def isnotnull(self) -> Expression: ...
def isnull(self) -> Expression: ...
def nulls_first(self) -> Expression: ...
def nulls_last(self) -> Expression: ...
def otherwise(self, value: IntoExpr) -> Expression: ...
def show(self) -> None: ...
def when(self, condition: IntoExpr, value: IntoExpr) -> Expression: ...
41 changes: 9 additions & 32 deletions _duckdb-stubs/_func.pyi
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
import typing
from typing import ClassVar
from ._enums import CppEnum

__all__: list[str] = ["ARROW", "DEFAULT", "NATIVE", "SPECIAL", "FunctionNullHandling", "PythonUDFType"]

class FunctionNullHandling:
DEFAULT: typing.ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.DEFAULT: 0>
SPECIAL: typing.ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.SPECIAL: 1>
__members__: typing.ClassVar[
class FunctionNullHandling(CppEnum):
DEFAULT: ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.DEFAULT: 0>
SPECIAL: ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.SPECIAL: 1>
__members__: ClassVar[
dict[str, FunctionNullHandling]
] # value = {'DEFAULT': <FunctionNullHandling.DEFAULT: 0>, 'SPECIAL': <FunctionNullHandling.SPECIAL: 1>}
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: typing.SupportsInt) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __setstate__(self, state: typing.SupportsInt) -> None: ...
@property
def name(self) -> str: ...
@property
def value(self) -> int: ...

class PythonUDFType:
ARROW: typing.ClassVar[PythonUDFType] # value = <PythonUDFType.ARROW: 1>
NATIVE: typing.ClassVar[PythonUDFType] # value = <PythonUDFType.NATIVE: 0>
__members__: typing.ClassVar[
ARROW: ClassVar[PythonUDFType] # value = <PythonUDFType.ARROW: 1>
NATIVE: ClassVar[PythonUDFType] # value = <PythonUDFType.NATIVE: 0>
__members__: ClassVar[
dict[str, PythonUDFType]
] # value = {'NATIVE': <PythonUDFType.NATIVE: 0>, 'ARROW': <PythonUDFType.ARROW: 1>}
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: typing.SupportsInt) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __setstate__(self, state: typing.SupportsInt) -> None: ...
@property
def name(self) -> str: ...
@property
def value(self) -> int: ...

ARROW: PythonUDFType # value = <PythonUDFType.ARROW: 1>
DEFAULT: FunctionNullHandling # value = <FunctionNullHandling.DEFAULT: 0>
Expand Down
5 changes: 3 additions & 2 deletions _duckdb-stubs/_sqltypes.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import duckdb
import typing
from ._typing import StrIntoPyType, PyTypeIds

__all__: list[str] = [
"BIGINT",
Expand Down Expand Up @@ -39,13 +40,13 @@ class DuckDBPyType:
def __getitem__(self, name: str) -> DuckDBPyType: ...
def __hash__(self) -> int: ...
@typing.overload
def __init__(self, type_str: str, connection: duckdb.DuckDBPyConnection) -> None: ...
def __init__(self, type_str: StrIntoPyType, connection: duckdb.DuckDBPyConnection) -> None: ...
@typing.overload
def __init__(self, obj: object) -> None: ...
@property
def children(self) -> list[tuple[str, DuckDBPyType | int | list[str]]]: ...
@property
def id(self) -> str: ...
def id(self) -> PyTypeIds: ...

BIGINT: DuckDBPyType # value = BIGINT
BIT: DuckDBPyType # value = BIT
Expand Down
Loading
Loading