Skip to content

Commit 83218b6

Browse files
committed
deprecate typing and functional
1 parent f5d4e42 commit 83218b6

File tree

15 files changed

+268
-187
lines changed

15 files changed

+268
-187
lines changed

_duckdb-stubs/__init__.pyi

Lines changed: 132 additions & 140 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.

duckdb/_dbapi_type_object.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
- DuckDB Type System: https://duckdb.org/docs/sql/data_types/overview
2626
"""
2727

28-
import duckdb.typing as duckdb_typing
28+
from duckdb import sqltypes
2929

3030

3131
class DBAPITypeObject:
@@ -42,16 +42,16 @@ class DBAPITypeObject:
4242
types: A list of DuckDBPyType instances that belong to this type category.
4343
4444
Example:
45-
>>> string_types = DBAPITypeObject([duckdb_typing.VARCHAR, duckdb_typing.CHAR])
46-
>>> result = duckdb_typing.VARCHAR == string_types # True
47-
>>> result = duckdb_typing.INTEGER == string_types # False
45+
>>> string_types = DBAPITypeObject([sqltypes.VARCHAR, sqltypes.CHAR])
46+
>>> result = sqltypes.VARCHAR == string_types # True
47+
>>> result = sqltypes.INTEGER == string_types # False
4848
4949
Note:
5050
This follows the DB API 2.0 specification where type objects are compared
5151
using equality operators rather than isinstance() checks.
5252
"""
5353

54-
def __init__(self, types: list[duckdb_typing.DuckDBPyType]) -> None:
54+
def __init__(self, types: list[sqltypes.DuckDBPyType]) -> None:
5555
"""Initialize a DB API type object.
5656
5757
Args:
@@ -73,10 +73,10 @@ def __eq__(self, other: object) -> bool:
7373
True if other is a DuckDBPyType in this category, False otherwise.
7474
7575
Example:
76-
>>> NUMBER == duckdb_typing.INTEGER # True
77-
>>> NUMBER == duckdb_typing.VARCHAR # False
76+
>>> NUMBER == sqltypes.INTEGER # True
77+
>>> NUMBER == sqltypes.VARCHAR # False
7878
"""
79-
if isinstance(other, duckdb_typing.DuckDBPyType):
79+
if isinstance(other, sqltypes.DuckDBPyType):
8080
return other in self.types
8181
return False
8282

@@ -95,7 +95,7 @@ def __repr__(self) -> str:
9595

9696
# Define the standard DB API 2.0 type objects for DuckDB
9797

98-
STRING = DBAPITypeObject([duckdb_typing.VARCHAR])
98+
STRING = DBAPITypeObject([sqltypes.VARCHAR])
9999
"""
100100
STRING type object for text-based database columns.
101101
@@ -114,20 +114,20 @@ def __repr__(self) -> str:
114114

115115
NUMBER = DBAPITypeObject(
116116
[
117-
duckdb_typing.TINYINT,
118-
duckdb_typing.UTINYINT,
119-
duckdb_typing.SMALLINT,
120-
duckdb_typing.USMALLINT,
121-
duckdb_typing.INTEGER,
122-
duckdb_typing.UINTEGER,
123-
duckdb_typing.BIGINT,
124-
duckdb_typing.UBIGINT,
125-
duckdb_typing.HUGEINT,
126-
duckdb_typing.UHUGEINT,
127-
duckdb_typing.DuckDBPyType("BIGNUM"),
128-
duckdb_typing.DuckDBPyType("DECIMAL"),
129-
duckdb_typing.FLOAT,
130-
duckdb_typing.DOUBLE,
117+
sqltypes.TINYINT,
118+
sqltypes.UTINYINT,
119+
sqltypes.SMALLINT,
120+
sqltypes.USMALLINT,
121+
sqltypes.INTEGER,
122+
sqltypes.UINTEGER,
123+
sqltypes.BIGINT,
124+
sqltypes.UBIGINT,
125+
sqltypes.HUGEINT,
126+
sqltypes.UHUGEINT,
127+
sqltypes.DuckDBPyType("BIGNUM"),
128+
sqltypes.DuckDBPyType("DECIMAL"),
129+
sqltypes.FLOAT,
130+
sqltypes.DOUBLE,
131131
]
132132
)
133133
"""
@@ -162,14 +162,14 @@ def __repr__(self) -> str:
162162

163163
DATETIME = DBAPITypeObject(
164164
[
165-
duckdb_typing.DATE,
166-
duckdb_typing.TIME,
167-
duckdb_typing.TIME_TZ,
168-
duckdb_typing.TIMESTAMP,
169-
duckdb_typing.TIMESTAMP_TZ,
170-
duckdb_typing.TIMESTAMP_NS,
171-
duckdb_typing.TIMESTAMP_MS,
172-
duckdb_typing.TIMESTAMP_S,
165+
sqltypes.DATE,
166+
sqltypes.TIME,
167+
sqltypes.TIME_TZ,
168+
sqltypes.TIMESTAMP,
169+
sqltypes.TIMESTAMP_TZ,
170+
sqltypes.TIMESTAMP_NS,
171+
sqltypes.TIMESTAMP_MS,
172+
sqltypes.TIMESTAMP_S,
173173
]
174174
)
175175
"""
@@ -201,7 +201,7 @@ def __repr__(self) -> str:
201201
>>> cursor.description[2][1] == DATETIME # Check if third column is date/time
202202
"""
203203

204-
BINARY = DBAPITypeObject([duckdb_typing.BLOB])
204+
BINARY = DBAPITypeObject([sqltypes.BLOB])
205205
"""
206206
BINARY type object for binary data database columns.
207207

duckdb/bytes_io_wrapper.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from io import StringIO, TextIOBase # noqa: D100
2-
from typing import Any, Union
1+
"""StringIO buffer wrapper.
32
4-
"""
53
BSD 3-Clause License
64
75
Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
@@ -35,10 +33,16 @@
3533
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3634
"""
3735

36+
from io import StringIO, TextIOBase
37+
from typing import Any, Union
38+
39+
40+
class BytesIOWrapper:
41+
"""Wrapper that wraps a StringIO buffer and reads bytes from it.
42+
43+
Created for compat with pyarrow read_csv.
44+
"""
3845

39-
class BytesIOWrapper: # noqa: D101
40-
# Wrapper that wraps a StringIO buffer and reads bytes from it
41-
# Created for compat with pyarrow read_csv
4246
def __init__(self, buffer: Union[StringIO, TextIOBase], encoding: str = "utf-8") -> None: # noqa: D107
4347
self.buffer = buffer
4448
self.encoding = encoding

duckdb/experimental/spark/sql/column.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ._typing import DateTimeLiteral, DecimalLiteral, LiteralType
99

1010
from duckdb import ColumnExpression, ConstantExpression, Expression, FunctionExpression
11-
from duckdb.typing import DuckDBPyType
11+
from duckdb.sqltypes import DuckDBPyType
1212

1313
__all__ = ["Column"]
1414

duckdb/experimental/spark/sql/type_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import cast # noqa: D100
22

3-
from duckdb.typing import DuckDBPyType
3+
from duckdb.sqltypes import DuckDBPyType
44

55
from .types import (
66
ArrayType,

duckdb/experimental/spark/sql/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424
import duckdb
25-
from duckdb.typing import DuckDBPyType
25+
from duckdb.sqltypes import DuckDBPyType
2626

2727
from ..exception import ContributionsAcceptedError
2828

duckdb/func/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from _duckdb._func import ARROW, DEFAULT, NATIVE, SPECIAL, FunctionNullHandling, PythonUDFType # noqa: D104
2+
3+
__all__ = ["ARROW", "DEFAULT", "NATIVE", "SPECIAL", "FunctionNullHandling", "PythonUDFType"]

duckdb/functional/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
from _duckdb.functional import ARROW, DEFAULT, NATIVE, SPECIAL, FunctionNullHandling, PythonUDFType # noqa: D104
1+
"""DuckDB function constants and types. DEPRECATED: please use `duckdb.func` instead."""
2+
3+
import warnings
4+
5+
from duckdb.func import ARROW, DEFAULT, NATIVE, SPECIAL, FunctionNullHandling, PythonUDFType
26

37
__all__ = ["ARROW", "DEFAULT", "NATIVE", "SPECIAL", "FunctionNullHandling", "PythonUDFType"]
8+
9+
warnings.warn(
10+
"`duckdb.functional` is deprecated and will be removed in a future version. Please use `duckdb.func` instead.",
11+
DeprecationWarning,
12+
stacklevel=2,
13+
)

0 commit comments

Comments
 (0)