Skip to content

Commit 89f2b8f

Browse files
Adding stubs and making mypy pass (duckdb#96)
Fixes duckdb#57 - Created and curated new stubs - Added py.typed - Added mypy config - Copied the typing and functional modules into sqltypes and func and deprecated the originals, to prevent shadowing issues
2 parents 27b1d79 + 21762d5 commit 89f2b8f

File tree

30 files changed

+2301
-1744
lines changed

30 files changed

+2301
-1744
lines changed

_duckdb-stubs/__init__.pyi

Lines changed: 1443 additions & 0 deletions
Large diffs are not rendered by default.

_duckdb-stubs/_func.pyi

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import typing as pytyping
2+
3+
__all__: list[str] = ["ARROW", "DEFAULT", "NATIVE", "SPECIAL", "FunctionNullHandling", "PythonUDFType"]
4+
5+
class FunctionNullHandling:
6+
DEFAULT: pytyping.ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.DEFAULT: 0>
7+
SPECIAL: pytyping.ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.SPECIAL: 1>
8+
__members__: pytyping.ClassVar[
9+
dict[str, FunctionNullHandling]
10+
] # value = {'DEFAULT': <FunctionNullHandling.DEFAULT: 0>, 'SPECIAL': <FunctionNullHandling.SPECIAL: 1>}
11+
def __eq__(self, other: object) -> bool: ...
12+
def __getstate__(self) -> int: ...
13+
def __hash__(self) -> int: ...
14+
def __index__(self) -> int: ...
15+
def __init__(self, value: pytyping.SupportsInt) -> None: ...
16+
def __int__(self) -> int: ...
17+
def __ne__(self, other: object) -> bool: ...
18+
def __setstate__(self, state: pytyping.SupportsInt) -> None: ...
19+
@property
20+
def name(self) -> str: ...
21+
@property
22+
def value(self) -> int: ...
23+
24+
class PythonUDFType:
25+
ARROW: pytyping.ClassVar[PythonUDFType] # value = <PythonUDFType.ARROW: 1>
26+
NATIVE: pytyping.ClassVar[PythonUDFType] # value = <PythonUDFType.NATIVE: 0>
27+
__members__: pytyping.ClassVar[
28+
dict[str, PythonUDFType]
29+
] # value = {'NATIVE': <PythonUDFType.NATIVE: 0>, 'ARROW': <PythonUDFType.ARROW: 1>}
30+
def __eq__(self, other: object) -> bool: ...
31+
def __getstate__(self) -> int: ...
32+
def __hash__(self) -> int: ...
33+
def __index__(self) -> int: ...
34+
def __init__(self, value: pytyping.SupportsInt) -> None: ...
35+
def __int__(self) -> int: ...
36+
def __ne__(self, other: object) -> bool: ...
37+
def __setstate__(self, state: pytyping.SupportsInt) -> None: ...
38+
@property
39+
def name(self) -> str: ...
40+
@property
41+
def value(self) -> int: ...
42+
43+
ARROW: PythonUDFType # value = <PythonUDFType.ARROW: 1>
44+
DEFAULT: FunctionNullHandling # value = <FunctionNullHandling.DEFAULT: 0>
45+
NATIVE: PythonUDFType # value = <PythonUDFType.NATIVE: 0>
46+
SPECIAL: FunctionNullHandling # value = <FunctionNullHandling.SPECIAL: 1>

_duckdb-stubs/_sqltypes.pyi

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import duckdb
2+
import typing as pytyping
3+
4+
__all__: list[str] = [
5+
"BIGINT",
6+
"BIT",
7+
"BLOB",
8+
"BOOLEAN",
9+
"DATE",
10+
"DOUBLE",
11+
"FLOAT",
12+
"HUGEINT",
13+
"INTEGER",
14+
"INTERVAL",
15+
"SMALLINT",
16+
"SQLNULL",
17+
"TIME",
18+
"TIMESTAMP",
19+
"TIMESTAMP_MS",
20+
"TIMESTAMP_NS",
21+
"TIMESTAMP_S",
22+
"TIMESTAMP_TZ",
23+
"TIME_TZ",
24+
"TINYINT",
25+
"UBIGINT",
26+
"UHUGEINT",
27+
"UINTEGER",
28+
"USMALLINT",
29+
"UTINYINT",
30+
"UUID",
31+
"VARCHAR",
32+
"DuckDBPyType",
33+
]
34+
35+
class DuckDBPyType:
36+
def __eq__(self, other: object) -> bool: ...
37+
def __getattr__(self, name: str) -> DuckDBPyType: ...
38+
def __getitem__(self, name: str) -> DuckDBPyType: ...
39+
def __hash__(self) -> int: ...
40+
@pytyping.overload
41+
def __init__(self, type_str: str, connection: duckdb.DuckDBPyConnection) -> None: ...
42+
@pytyping.overload
43+
def __init__(self, obj: object) -> None: ...
44+
@property
45+
def children(self) -> list[tuple[str, object]]: ...
46+
@property
47+
def id(self) -> str: ...
48+
49+
BIGINT: DuckDBPyType # value = BIGINT
50+
BIT: DuckDBPyType # value = BIT
51+
BLOB: DuckDBPyType # value = BLOB
52+
BOOLEAN: DuckDBPyType # value = BOOLEAN
53+
DATE: DuckDBPyType # value = DATE
54+
DOUBLE: DuckDBPyType # value = DOUBLE
55+
FLOAT: DuckDBPyType # value = FLOAT
56+
HUGEINT: DuckDBPyType # value = HUGEINT
57+
INTEGER: DuckDBPyType # value = INTEGER
58+
INTERVAL: DuckDBPyType # value = INTERVAL
59+
SMALLINT: DuckDBPyType # value = SMALLINT
60+
SQLNULL: DuckDBPyType # value = "NULL"
61+
TIME: DuckDBPyType # value = TIME
62+
TIMESTAMP: DuckDBPyType # value = TIMESTAMP
63+
TIMESTAMP_MS: DuckDBPyType # value = TIMESTAMP_MS
64+
TIMESTAMP_NS: DuckDBPyType # value = TIMESTAMP_NS
65+
TIMESTAMP_S: DuckDBPyType # value = TIMESTAMP_S
66+
TIMESTAMP_TZ: DuckDBPyType # value = TIMESTAMP WITH TIME ZONE
67+
TIME_TZ: DuckDBPyType # value = TIME WITH TIME ZONE
68+
TINYINT: DuckDBPyType # value = TINYINT
69+
UBIGINT: DuckDBPyType # value = UBIGINT
70+
UHUGEINT: DuckDBPyType # value = UHUGEINT
71+
UINTEGER: DuckDBPyType # value = UINTEGER
72+
USMALLINT: DuckDBPyType # value = USMALLINT
73+
UTINYINT: DuckDBPyType # value = UTINYINT
74+
UUID: DuckDBPyType # value = UUID
75+
VARCHAR: DuckDBPyType # value = VARCHAR

0 commit comments

Comments
 (0)