sqlspec 0.14.0__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sqlspec might be problematic. Click here for more details.
- sqlspec/__init__.py +50 -25
- sqlspec/__main__.py +12 -0
- sqlspec/__metadata__.py +1 -3
- sqlspec/_serialization.py +1 -2
- sqlspec/_sql.py +256 -120
- sqlspec/_typing.py +278 -142
- sqlspec/adapters/adbc/__init__.py +4 -3
- sqlspec/adapters/adbc/_types.py +12 -0
- sqlspec/adapters/adbc/config.py +115 -248
- sqlspec/adapters/adbc/driver.py +462 -353
- sqlspec/adapters/aiosqlite/__init__.py +18 -3
- sqlspec/adapters/aiosqlite/_types.py +13 -0
- sqlspec/adapters/aiosqlite/config.py +199 -129
- sqlspec/adapters/aiosqlite/driver.py +230 -269
- sqlspec/adapters/asyncmy/__init__.py +18 -3
- sqlspec/adapters/asyncmy/_types.py +12 -0
- sqlspec/adapters/asyncmy/config.py +80 -168
- sqlspec/adapters/asyncmy/driver.py +260 -225
- sqlspec/adapters/asyncpg/__init__.py +19 -4
- sqlspec/adapters/asyncpg/_types.py +17 -0
- sqlspec/adapters/asyncpg/config.py +82 -181
- sqlspec/adapters/asyncpg/driver.py +285 -383
- sqlspec/adapters/bigquery/__init__.py +17 -3
- sqlspec/adapters/bigquery/_types.py +12 -0
- sqlspec/adapters/bigquery/config.py +191 -258
- sqlspec/adapters/bigquery/driver.py +474 -646
- sqlspec/adapters/duckdb/__init__.py +14 -3
- sqlspec/adapters/duckdb/_types.py +12 -0
- sqlspec/adapters/duckdb/config.py +415 -351
- sqlspec/adapters/duckdb/driver.py +343 -413
- sqlspec/adapters/oracledb/__init__.py +19 -5
- sqlspec/adapters/oracledb/_types.py +14 -0
- sqlspec/adapters/oracledb/config.py +123 -379
- sqlspec/adapters/oracledb/driver.py +507 -560
- sqlspec/adapters/psqlpy/__init__.py +13 -3
- sqlspec/adapters/psqlpy/_types.py +11 -0
- sqlspec/adapters/psqlpy/config.py +93 -254
- sqlspec/adapters/psqlpy/driver.py +505 -234
- sqlspec/adapters/psycopg/__init__.py +19 -5
- sqlspec/adapters/psycopg/_types.py +17 -0
- sqlspec/adapters/psycopg/config.py +143 -403
- sqlspec/adapters/psycopg/driver.py +706 -872
- sqlspec/adapters/sqlite/__init__.py +14 -3
- sqlspec/adapters/sqlite/_types.py +11 -0
- sqlspec/adapters/sqlite/config.py +202 -118
- sqlspec/adapters/sqlite/driver.py +264 -303
- sqlspec/base.py +105 -9
- sqlspec/{statement/builder → builder}/__init__.py +12 -14
- sqlspec/{statement/builder → builder}/_base.py +120 -55
- sqlspec/{statement/builder → builder}/_column.py +17 -6
- sqlspec/{statement/builder → builder}/_ddl.py +46 -79
- sqlspec/{statement/builder → builder}/_ddl_utils.py +5 -10
- sqlspec/{statement/builder → builder}/_delete.py +6 -25
- sqlspec/{statement/builder → builder}/_insert.py +6 -64
- sqlspec/builder/_merge.py +56 -0
- sqlspec/{statement/builder → builder}/_parsing_utils.py +3 -10
- sqlspec/{statement/builder → builder}/_select.py +11 -56
- sqlspec/{statement/builder → builder}/_update.py +12 -18
- sqlspec/{statement/builder → builder}/mixins/__init__.py +10 -14
- sqlspec/{statement/builder → builder}/mixins/_cte_and_set_ops.py +48 -59
- sqlspec/{statement/builder → builder}/mixins/_insert_operations.py +22 -16
- sqlspec/{statement/builder → builder}/mixins/_join_operations.py +1 -3
- sqlspec/{statement/builder → builder}/mixins/_merge_operations.py +3 -5
- sqlspec/{statement/builder → builder}/mixins/_order_limit_operations.py +3 -3
- sqlspec/{statement/builder → builder}/mixins/_pivot_operations.py +4 -8
- sqlspec/{statement/builder → builder}/mixins/_select_operations.py +21 -36
- sqlspec/{statement/builder → builder}/mixins/_update_operations.py +3 -14
- sqlspec/{statement/builder → builder}/mixins/_where_clause.py +52 -79
- sqlspec/cli.py +4 -5
- sqlspec/config.py +180 -133
- sqlspec/core/__init__.py +63 -0
- sqlspec/core/cache.py +873 -0
- sqlspec/core/compiler.py +396 -0
- sqlspec/core/filters.py +828 -0
- sqlspec/core/hashing.py +310 -0
- sqlspec/core/parameters.py +1209 -0
- sqlspec/core/result.py +664 -0
- sqlspec/{statement → core}/splitter.py +321 -191
- sqlspec/core/statement.py +651 -0
- sqlspec/driver/__init__.py +7 -10
- sqlspec/driver/_async.py +387 -176
- sqlspec/driver/_common.py +527 -289
- sqlspec/driver/_sync.py +390 -172
- sqlspec/driver/mixins/__init__.py +2 -19
- sqlspec/driver/mixins/_result_tools.py +168 -0
- sqlspec/driver/mixins/_sql_translator.py +6 -3
- sqlspec/exceptions.py +5 -252
- sqlspec/extensions/aiosql/adapter.py +93 -96
- sqlspec/extensions/litestar/config.py +0 -1
- sqlspec/extensions/litestar/handlers.py +15 -26
- sqlspec/extensions/litestar/plugin.py +16 -14
- sqlspec/extensions/litestar/providers.py +17 -52
- sqlspec/loader.py +424 -105
- sqlspec/migrations/__init__.py +12 -0
- sqlspec/migrations/base.py +92 -68
- sqlspec/migrations/commands.py +24 -106
- sqlspec/migrations/loaders.py +402 -0
- sqlspec/migrations/runner.py +49 -51
- sqlspec/migrations/tracker.py +31 -44
- sqlspec/migrations/utils.py +64 -24
- sqlspec/protocols.py +7 -183
- sqlspec/storage/__init__.py +1 -1
- sqlspec/storage/backends/base.py +37 -40
- sqlspec/storage/backends/fsspec.py +136 -112
- sqlspec/storage/backends/obstore.py +138 -160
- sqlspec/storage/capabilities.py +5 -4
- sqlspec/storage/registry.py +57 -106
- sqlspec/typing.py +136 -115
- sqlspec/utils/__init__.py +2 -3
- sqlspec/utils/correlation.py +0 -3
- sqlspec/utils/deprecation.py +6 -6
- sqlspec/utils/fixtures.py +6 -6
- sqlspec/utils/logging.py +0 -2
- sqlspec/utils/module_loader.py +7 -12
- sqlspec/utils/singleton.py +0 -1
- sqlspec/utils/sync_tools.py +16 -37
- sqlspec/utils/text.py +12 -51
- sqlspec/utils/type_guards.py +443 -232
- {sqlspec-0.14.0.dist-info → sqlspec-0.15.0.dist-info}/METADATA +7 -2
- sqlspec-0.15.0.dist-info/RECORD +134 -0
- sqlspec-0.15.0.dist-info/entry_points.txt +2 -0
- sqlspec/driver/connection.py +0 -207
- sqlspec/driver/mixins/_cache.py +0 -114
- sqlspec/driver/mixins/_csv_writer.py +0 -91
- sqlspec/driver/mixins/_pipeline.py +0 -508
- sqlspec/driver/mixins/_query_tools.py +0 -796
- sqlspec/driver/mixins/_result_utils.py +0 -138
- sqlspec/driver/mixins/_storage.py +0 -912
- sqlspec/driver/mixins/_type_coercion.py +0 -128
- sqlspec/driver/parameters.py +0 -138
- sqlspec/statement/__init__.py +0 -21
- sqlspec/statement/builder/_merge.py +0 -95
- sqlspec/statement/cache.py +0 -50
- sqlspec/statement/filters.py +0 -625
- sqlspec/statement/parameters.py +0 -996
- sqlspec/statement/pipelines/__init__.py +0 -210
- sqlspec/statement/pipelines/analyzers/__init__.py +0 -9
- sqlspec/statement/pipelines/analyzers/_analyzer.py +0 -646
- sqlspec/statement/pipelines/context.py +0 -115
- sqlspec/statement/pipelines/transformers/__init__.py +0 -7
- sqlspec/statement/pipelines/transformers/_expression_simplifier.py +0 -88
- sqlspec/statement/pipelines/transformers/_literal_parameterizer.py +0 -1247
- sqlspec/statement/pipelines/transformers/_remove_comments_and_hints.py +0 -76
- sqlspec/statement/pipelines/validators/__init__.py +0 -23
- sqlspec/statement/pipelines/validators/_dml_safety.py +0 -290
- sqlspec/statement/pipelines/validators/_parameter_style.py +0 -370
- sqlspec/statement/pipelines/validators/_performance.py +0 -714
- sqlspec/statement/pipelines/validators/_security.py +0 -967
- sqlspec/statement/result.py +0 -435
- sqlspec/statement/sql.py +0 -1774
- sqlspec/utils/cached_property.py +0 -25
- sqlspec/utils/statement_hashing.py +0 -203
- sqlspec-0.14.0.dist-info/RECORD +0 -143
- sqlspec-0.14.0.dist-info/entry_points.txt +0 -2
- /sqlspec/{statement/builder → builder}/mixins/_delete_operations.py +0 -0
- {sqlspec-0.14.0.dist-info → sqlspec-0.15.0.dist-info}/WHEEL +0 -0
- {sqlspec-0.14.0.dist-info → sqlspec-0.15.0.dist-info}/licenses/LICENSE +0 -0
- {sqlspec-0.14.0.dist-info → sqlspec-0.15.0.dist-info}/licenses/NOTICE +0 -0
sqlspec/_typing.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
# ruff: noqa: RUF100, PLR0913, A002, DOC201, PLR6301, PLR0917, ARG004
|
|
2
|
-
"""
|
|
3
|
-
|
|
4
|
-
This is used to ensure compatibility when one or more of the libraries are installed.
|
|
5
|
-
"""
|
|
1
|
+
# ruff: noqa: RUF100, PLR0913, A002, DOC201, PLR6301, PLR0917, ARG004, ARG002, ARG001
|
|
2
|
+
"""Wrapper around library classes for compatibility when libraries are installed."""
|
|
6
3
|
|
|
4
|
+
import enum
|
|
7
5
|
from collections.abc import Iterable, Mapping
|
|
6
|
+
from dataclasses import dataclass
|
|
8
7
|
from enum import Enum
|
|
9
8
|
from importlib.util import find_spec
|
|
10
9
|
from typing import Any, ClassVar, Final, Optional, Protocol, Union, cast, runtime_checkable
|
|
@@ -14,11 +13,7 @@ from typing_extensions import Literal, TypeVar, dataclass_transform
|
|
|
14
13
|
|
|
15
14
|
@runtime_checkable
|
|
16
15
|
class DataclassProtocol(Protocol):
|
|
17
|
-
"""Protocol for instance checking dataclasses.
|
|
18
|
-
|
|
19
|
-
This protocol only requires the presence of `__dataclass_fields__`, which is the
|
|
20
|
-
standard attribute that Python's dataclasses module adds to all dataclass instances.
|
|
21
|
-
"""
|
|
16
|
+
"""Protocol for instance checking dataclasses."""
|
|
22
17
|
|
|
23
18
|
__dataclass_fields__: "ClassVar[dict[str, Any]]"
|
|
24
19
|
|
|
@@ -26,160 +21,277 @@ class DataclassProtocol(Protocol):
|
|
|
26
21
|
T = TypeVar("T")
|
|
27
22
|
T_co = TypeVar("T_co", covariant=True)
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
from pydantic import (
|
|
31
|
-
BaseModel, # pyright: ignore[reportAssignmentType]
|
|
32
|
-
FailFast, # pyright: ignore[reportGeneralTypeIssues,reportAssignmentType]
|
|
33
|
-
TypeAdapter,
|
|
34
|
-
)
|
|
24
|
+
# Always define stub types for type checking
|
|
35
25
|
|
|
36
|
-
PYDANTIC_INSTALLED = True
|
|
37
|
-
except ImportError:
|
|
38
|
-
from dataclasses import dataclass
|
|
39
26
|
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
class BaseModelStub:
|
|
28
|
+
"""Placeholder implementation."""
|
|
42
29
|
|
|
43
|
-
|
|
30
|
+
model_fields: ClassVar[dict[str, Any]] = {}
|
|
31
|
+
__slots__ = ("__dict__", "__pydantic_extra__", "__pydantic_fields_set__", "__pydantic_private__")
|
|
44
32
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*,
|
|
49
|
-
include: "Optional[Any]" = None,
|
|
50
|
-
exclude: "Optional[Any]" = None,
|
|
51
|
-
context: "Optional[Any]" = None,
|
|
52
|
-
by_alias: bool = False,
|
|
53
|
-
exclude_unset: bool = False,
|
|
54
|
-
exclude_defaults: bool = False,
|
|
55
|
-
exclude_none: bool = False,
|
|
56
|
-
round_trip: bool = False,
|
|
57
|
-
warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True,
|
|
58
|
-
serialize_as_any: bool = False,
|
|
59
|
-
) -> "dict[str, Any]":
|
|
60
|
-
"""Placeholder"""
|
|
61
|
-
return {}
|
|
62
|
-
|
|
63
|
-
def model_dump_json(
|
|
64
|
-
self,
|
|
65
|
-
/,
|
|
66
|
-
*,
|
|
67
|
-
include: "Optional[Any]" = None,
|
|
68
|
-
exclude: "Optional[Any]" = None,
|
|
69
|
-
context: "Optional[Any]" = None,
|
|
70
|
-
by_alias: bool = False,
|
|
71
|
-
exclude_unset: bool = False,
|
|
72
|
-
exclude_defaults: bool = False,
|
|
73
|
-
exclude_none: bool = False,
|
|
74
|
-
round_trip: bool = False,
|
|
75
|
-
warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True,
|
|
76
|
-
serialize_as_any: bool = False,
|
|
77
|
-
) -> str:
|
|
78
|
-
"""Placeholder"""
|
|
79
|
-
return ""
|
|
33
|
+
def __init__(self, **data: Any) -> None:
|
|
34
|
+
for key, value in data.items():
|
|
35
|
+
setattr(self, key, value)
|
|
80
36
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
37
|
+
def model_dump( # noqa: PLR0913
|
|
38
|
+
self,
|
|
39
|
+
/,
|
|
40
|
+
*,
|
|
41
|
+
include: "Optional[Any]" = None, # noqa: ARG002
|
|
42
|
+
exclude: "Optional[Any]" = None, # noqa: ARG002
|
|
43
|
+
context: "Optional[Any]" = None, # noqa: ARG002
|
|
44
|
+
by_alias: bool = False, # noqa: ARG002
|
|
45
|
+
exclude_unset: bool = False, # noqa: ARG002
|
|
46
|
+
exclude_defaults: bool = False, # noqa: ARG002
|
|
47
|
+
exclude_none: bool = False, # noqa: ARG002
|
|
48
|
+
round_trip: bool = False, # noqa: ARG002
|
|
49
|
+
warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True, # noqa: ARG002
|
|
50
|
+
serialize_as_any: bool = False, # noqa: ARG002
|
|
51
|
+
) -> "dict[str, Any]":
|
|
52
|
+
"""Placeholder implementation."""
|
|
53
|
+
return {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
|
|
54
|
+
|
|
55
|
+
def model_dump_json( # noqa: PLR0913
|
|
56
|
+
self,
|
|
57
|
+
/,
|
|
58
|
+
*,
|
|
59
|
+
include: "Optional[Any]" = None, # noqa: ARG002
|
|
60
|
+
exclude: "Optional[Any]" = None, # noqa: ARG002
|
|
61
|
+
context: "Optional[Any]" = None, # noqa: ARG002
|
|
62
|
+
by_alias: bool = False, # noqa: ARG002
|
|
63
|
+
exclude_unset: bool = False, # noqa: ARG002
|
|
64
|
+
exclude_defaults: bool = False, # noqa: ARG002
|
|
65
|
+
exclude_none: bool = False, # noqa: ARG002
|
|
66
|
+
round_trip: bool = False, # noqa: ARG002
|
|
67
|
+
warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True, # noqa: ARG002
|
|
68
|
+
serialize_as_any: bool = False, # noqa: ARG002
|
|
69
|
+
) -> str:
|
|
70
|
+
"""Placeholder implementation."""
|
|
71
|
+
return "{}"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class TypeAdapterStub:
|
|
75
|
+
"""Placeholder implementation."""
|
|
76
|
+
|
|
77
|
+
def __init__(
|
|
78
|
+
self,
|
|
79
|
+
type: Any, # noqa: A002
|
|
80
|
+
*,
|
|
81
|
+
config: "Optional[Any]" = None, # noqa: ARG002
|
|
82
|
+
_parent_depth: int = 2, # noqa: ARG002
|
|
83
|
+
module: "Optional[str]" = None, # noqa: ARG002
|
|
84
|
+
) -> None:
|
|
85
|
+
"""Initialize."""
|
|
86
|
+
self._type = type
|
|
87
|
+
|
|
88
|
+
def validate_python( # noqa: PLR0913
|
|
89
|
+
self,
|
|
90
|
+
object: Any,
|
|
91
|
+
/,
|
|
92
|
+
*,
|
|
93
|
+
strict: "Optional[bool]" = None, # noqa: ARG002
|
|
94
|
+
from_attributes: "Optional[bool]" = None, # noqa: ARG002
|
|
95
|
+
context: "Optional[dict[str, Any]]" = None, # noqa: ARG002
|
|
96
|
+
experimental_allow_partial: "Union[bool, Literal['off', 'on', 'trailing-strings']]" = False, # noqa: ARG002
|
|
97
|
+
) -> Any:
|
|
98
|
+
"""Validate Python object."""
|
|
99
|
+
return object
|
|
84
100
|
|
|
85
|
-
def __init__(
|
|
86
|
-
self,
|
|
87
|
-
type: Any, # noqa: A002
|
|
88
|
-
*,
|
|
89
|
-
config: "Optional[Any]" = None,
|
|
90
|
-
_parent_depth: int = 2,
|
|
91
|
-
module: "Optional[str]" = None,
|
|
92
|
-
) -> None:
|
|
93
|
-
"""Init"""
|
|
94
101
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
/,
|
|
99
|
-
*,
|
|
100
|
-
strict: "Optional[bool]" = None,
|
|
101
|
-
from_attributes: "Optional[bool]" = None,
|
|
102
|
-
context: "Optional[dict[str, Any]]" = None,
|
|
103
|
-
experimental_allow_partial: "Union[bool, Literal['off', 'on', 'trailing-strings']]" = False,
|
|
104
|
-
) -> "T_co":
|
|
105
|
-
"""Stub"""
|
|
106
|
-
return cast("T_co", object)
|
|
107
|
-
|
|
108
|
-
@dataclass
|
|
109
|
-
class FailFast: # type: ignore[no-redef]
|
|
110
|
-
"""Placeholder Implementation for FailFast"""
|
|
111
|
-
|
|
112
|
-
fail_fast: bool = True
|
|
102
|
+
@dataclass
|
|
103
|
+
class FailFastStub:
|
|
104
|
+
"""Placeholder implementation for FailFast."""
|
|
113
105
|
|
|
114
|
-
|
|
106
|
+
fail_fast: bool = True
|
|
115
107
|
|
|
116
|
-
try:
|
|
117
|
-
from msgspec import (
|
|
118
|
-
UNSET,
|
|
119
|
-
Struct,
|
|
120
|
-
UnsetType, # pyright: ignore[reportAssignmentType,reportGeneralTypeIssues]
|
|
121
|
-
convert,
|
|
122
|
-
)
|
|
123
108
|
|
|
124
|
-
|
|
109
|
+
# Try to import real implementations at runtime
|
|
110
|
+
try:
|
|
111
|
+
from pydantic import BaseModel as _RealBaseModel
|
|
112
|
+
from pydantic import FailFast as _RealFailFast
|
|
113
|
+
from pydantic import TypeAdapter as _RealTypeAdapter
|
|
114
|
+
|
|
115
|
+
BaseModel = _RealBaseModel
|
|
116
|
+
TypeAdapter = _RealTypeAdapter
|
|
117
|
+
FailFast = _RealFailFast
|
|
118
|
+
PYDANTIC_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
125
119
|
except ImportError:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
BaseModel = BaseModelStub # type: ignore[assignment,misc]
|
|
121
|
+
TypeAdapter = TypeAdapterStub # type: ignore[assignment,misc]
|
|
122
|
+
FailFast = FailFastStub # type: ignore[assignment,misc]
|
|
123
|
+
PYDANTIC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
129
124
|
|
|
130
|
-
|
|
131
|
-
@runtime_checkable
|
|
132
|
-
class Struct(Protocol): # type: ignore[no-redef]
|
|
133
|
-
"""Placeholder Implementation"""
|
|
125
|
+
# Always define stub types for msgspec
|
|
134
126
|
|
|
135
|
-
__struct_fields__: "ClassVar[tuple[str, ...]]"
|
|
136
127
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
128
|
+
@dataclass_transform()
|
|
129
|
+
class StructStub:
|
|
130
|
+
"""Placeholder implementation."""
|
|
131
|
+
|
|
132
|
+
__struct_fields__: ClassVar[tuple[str, ...]] = ()
|
|
133
|
+
__slots__ = ()
|
|
134
|
+
|
|
135
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
136
|
+
for key, value in kwargs.items():
|
|
137
|
+
setattr(self, key, value)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def convert_stub( # noqa: PLR0913
|
|
141
|
+
obj: Any, # noqa: ARG001
|
|
142
|
+
type: Any, # noqa: A002,ARG001
|
|
143
|
+
*,
|
|
144
|
+
strict: bool = True, # noqa: ARG001
|
|
145
|
+
from_attributes: bool = False, # noqa: ARG001
|
|
146
|
+
dec_hook: "Optional[Any]" = None, # noqa: ARG001
|
|
147
|
+
builtin_types: "Optional[Any]" = None, # noqa: ARG001
|
|
148
|
+
str_keys: bool = False, # noqa: ARG001
|
|
149
|
+
) -> Any:
|
|
150
|
+
"""Placeholder implementation."""
|
|
151
|
+
return {}
|
|
149
152
|
|
|
150
|
-
class UnsetType(enum.Enum): # type: ignore[no-redef]
|
|
151
|
-
UNSET = "UNSET"
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
class UnsetTypeStub(enum.Enum):
|
|
155
|
+
UNSET = "UNSET"
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
UNSET_STUB = UnsetTypeStub.UNSET
|
|
159
|
+
|
|
160
|
+
# Try to import real implementations at runtime
|
|
161
|
+
try:
|
|
162
|
+
from msgspec import UNSET as _REAL_UNSET
|
|
163
|
+
from msgspec import Struct as _RealStruct
|
|
164
|
+
from msgspec import UnsetType as _RealUnsetType
|
|
165
|
+
from msgspec import convert as _real_convert
|
|
166
|
+
|
|
167
|
+
Struct = _RealStruct
|
|
168
|
+
UnsetType = _RealUnsetType
|
|
169
|
+
UNSET = _REAL_UNSET
|
|
170
|
+
convert = _real_convert
|
|
171
|
+
MSGSPEC_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
172
|
+
except ImportError:
|
|
173
|
+
Struct = StructStub # type: ignore[assignment,misc]
|
|
174
|
+
UnsetType = UnsetTypeStub # type: ignore[assignment,misc]
|
|
175
|
+
UNSET = UNSET_STUB # type: ignore[assignment] # pyright: ignore[reportConstantRedefinition]
|
|
176
|
+
convert = convert_stub
|
|
154
177
|
MSGSPEC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
155
178
|
|
|
179
|
+
|
|
180
|
+
# Always define stub type for DTOData
|
|
181
|
+
@runtime_checkable
|
|
182
|
+
class DTODataStub(Protocol[T]):
|
|
183
|
+
"""Placeholder implementation."""
|
|
184
|
+
|
|
185
|
+
__slots__ = ("_backend", "_data_as_builtins")
|
|
186
|
+
|
|
187
|
+
def __init__(self, backend: Any, data_as_builtins: Any) -> None:
|
|
188
|
+
"""Initialize."""
|
|
189
|
+
|
|
190
|
+
def create_instance(self, **kwargs: Any) -> T:
|
|
191
|
+
return cast("T", kwargs)
|
|
192
|
+
|
|
193
|
+
def update_instance(self, instance: T, **kwargs: Any) -> T:
|
|
194
|
+
"""Update instance."""
|
|
195
|
+
return cast("T", kwargs)
|
|
196
|
+
|
|
197
|
+
def as_builtins(self) -> Any:
|
|
198
|
+
"""Convert to builtins."""
|
|
199
|
+
return {}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
# Try to import real implementation at runtime
|
|
156
203
|
try:
|
|
157
|
-
from litestar.dto.data_structures import DTOData # pyright: ignore[reportUnknownVariableType]
|
|
204
|
+
from litestar.dto.data_structures import DTOData as _RealDTOData # pyright: ignore[reportUnknownVariableType]
|
|
158
205
|
|
|
159
|
-
|
|
206
|
+
DTOData = _RealDTOData
|
|
207
|
+
LITESTAR_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
160
208
|
except ImportError:
|
|
209
|
+
DTOData = DTODataStub # type: ignore[assignment,misc]
|
|
210
|
+
LITESTAR_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
161
211
|
|
|
162
|
-
@runtime_checkable
|
|
163
|
-
class DTOData(Protocol[T]): # type: ignore[no-redef]
|
|
164
|
-
"""Placeholder implementation"""
|
|
165
212
|
|
|
166
|
-
|
|
213
|
+
# Always define stub types for attrs
|
|
214
|
+
@dataclass_transform()
|
|
215
|
+
class AttrsInstanceStub:
|
|
216
|
+
"""Placeholder Implementation for attrs classes"""
|
|
167
217
|
|
|
168
|
-
|
|
169
|
-
|
|
218
|
+
__attrs_attrs__: ClassVar[tuple[Any, ...]] = ()
|
|
219
|
+
__slots__ = ()
|
|
170
220
|
|
|
171
|
-
|
|
172
|
-
|
|
221
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
222
|
+
for key, value in kwargs.items():
|
|
223
|
+
setattr(self, key, value)
|
|
173
224
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return cast("T", kwargs)
|
|
225
|
+
def __repr__(self) -> str:
|
|
226
|
+
return f"{self.__class__.__name__}()"
|
|
177
227
|
|
|
178
|
-
def as_builtins(self) -> Any:
|
|
179
|
-
"""Placeholder implementation"""
|
|
180
|
-
return {}
|
|
181
228
|
|
|
182
|
-
|
|
229
|
+
def attrs_asdict_stub(*args: Any, **kwargs: Any) -> "dict[str, Any]": # noqa: ARG001
|
|
230
|
+
"""Placeholder implementation"""
|
|
231
|
+
return {}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def attrs_define_stub(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
235
|
+
"""Placeholder implementation"""
|
|
236
|
+
return lambda cls: cls # pyright: ignore[reportUnknownVariableType,reportUnknownLambdaType]
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def attrs_field_stub(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
240
|
+
"""Placeholder implementation"""
|
|
241
|
+
return None
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def attrs_fields_stub(*args: Any, **kwargs: Any) -> "tuple[Any, ...]": # noqa: ARG001
|
|
245
|
+
"""Placeholder implementation"""
|
|
246
|
+
return ()
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def attrs_has_stub(*args: Any, **kwargs: Any) -> bool: # noqa: ARG001
|
|
250
|
+
"""Placeholder implementation"""
|
|
251
|
+
return False
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
# Try to import real implementations at runtime
|
|
255
|
+
try:
|
|
256
|
+
from attrs import AttrsInstance as _RealAttrsInstance # pyright: ignore
|
|
257
|
+
from attrs import asdict as _real_attrs_asdict
|
|
258
|
+
from attrs import define as _real_attrs_define
|
|
259
|
+
from attrs import field as _real_attrs_field
|
|
260
|
+
from attrs import fields as _real_attrs_fields
|
|
261
|
+
from attrs import has as _real_attrs_has
|
|
262
|
+
|
|
263
|
+
AttrsInstance = _RealAttrsInstance
|
|
264
|
+
attrs_asdict = _real_attrs_asdict
|
|
265
|
+
attrs_define = _real_attrs_define
|
|
266
|
+
attrs_field = _real_attrs_field
|
|
267
|
+
attrs_fields = _real_attrs_fields
|
|
268
|
+
attrs_has = _real_attrs_has
|
|
269
|
+
ATTRS_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
270
|
+
except ImportError:
|
|
271
|
+
AttrsInstance = AttrsInstanceStub # type: ignore[misc]
|
|
272
|
+
attrs_asdict = attrs_asdict_stub
|
|
273
|
+
attrs_define = attrs_define_stub
|
|
274
|
+
attrs_field = attrs_field_stub
|
|
275
|
+
attrs_fields = attrs_fields_stub
|
|
276
|
+
attrs_has = attrs_has_stub # type: ignore[assignment]
|
|
277
|
+
ATTRS_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
278
|
+
|
|
279
|
+
try:
|
|
280
|
+
from cattrs import structure as cattrs_structure
|
|
281
|
+
from cattrs import unstructure as cattrs_unstructure
|
|
282
|
+
|
|
283
|
+
CATTRS_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
284
|
+
except ImportError:
|
|
285
|
+
|
|
286
|
+
def cattrs_unstructure(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
287
|
+
"""Placeholder implementation"""
|
|
288
|
+
return {}
|
|
289
|
+
|
|
290
|
+
def cattrs_structure(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
291
|
+
"""Placeholder implementation"""
|
|
292
|
+
return {}
|
|
293
|
+
|
|
294
|
+
CATTRS_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
|
|
183
295
|
|
|
184
296
|
|
|
185
297
|
class EmptyEnum(Enum):
|
|
@@ -278,7 +390,7 @@ try:
|
|
|
278
390
|
Tracer, # pyright: ignore[reportMissingImports, reportAssignmentType]
|
|
279
391
|
)
|
|
280
392
|
|
|
281
|
-
OPENTELEMETRY_INSTALLED = True
|
|
393
|
+
OPENTELEMETRY_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
282
394
|
except ImportError:
|
|
283
395
|
# Define shims for when opentelemetry is not installed
|
|
284
396
|
|
|
@@ -338,7 +450,7 @@ except ImportError:
|
|
|
338
450
|
trace = _TraceModule() # type: ignore[assignment]
|
|
339
451
|
StatusCode = trace.StatusCode # type: ignore[misc]
|
|
340
452
|
Status = trace.Status # type: ignore[misc]
|
|
341
|
-
OPENTELEMETRY_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
453
|
+
OPENTELEMETRY_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
|
|
342
454
|
|
|
343
455
|
|
|
344
456
|
try:
|
|
@@ -348,7 +460,7 @@ try:
|
|
|
348
460
|
Histogram, # pyright: ignore[reportAssignmentType]
|
|
349
461
|
)
|
|
350
462
|
|
|
351
|
-
PROMETHEUS_INSTALLED = True
|
|
463
|
+
PROMETHEUS_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
352
464
|
except ImportError:
|
|
353
465
|
# Define shims for when prometheus_client is not installed
|
|
354
466
|
|
|
@@ -394,7 +506,7 @@ except ImportError:
|
|
|
394
506
|
def labels(self, *labelvalues: str, **labelkwargs: str) -> _MetricInstance:
|
|
395
507
|
return _MetricInstance() # pragma: no cover
|
|
396
508
|
|
|
397
|
-
PROMETHEUS_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
509
|
+
PROMETHEUS_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
|
|
398
510
|
|
|
399
511
|
|
|
400
512
|
try:
|
|
@@ -413,7 +525,7 @@ try:
|
|
|
413
525
|
SyncDriverAdapterProtocol as AiosqlSyncProtocol, # pyright: ignore[reportMissingImports, reportAssignmentType]
|
|
414
526
|
)
|
|
415
527
|
|
|
416
|
-
AIOSQL_INSTALLED = True
|
|
528
|
+
AIOSQL_INSTALLED = True # pyright: ignore[reportConstantRedefinition]
|
|
417
529
|
except ImportError:
|
|
418
530
|
# Define shims for when aiosql is not installed
|
|
419
531
|
|
|
@@ -490,7 +602,7 @@ except ImportError:
|
|
|
490
602
|
async def insert_update_delete_many(self, conn: Any, query_name: str, sql: str, parameters: Any) -> None: ...
|
|
491
603
|
async def insert_returning(self, conn: Any, query_name: str, sql: str, parameters: Any) -> "Optional[Any]": ...
|
|
492
604
|
|
|
493
|
-
AIOSQL_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
605
|
+
AIOSQL_INSTALLED = False # pyright: ignore[reportConstantRedefinition] # pyright: ignore[reportConstantRedefinition]
|
|
494
606
|
|
|
495
607
|
|
|
496
608
|
FSSPEC_INSTALLED = bool(find_spec("fsspec"))
|
|
@@ -500,6 +612,8 @@ PGVECTOR_INSTALLED = bool(find_spec("pgvector"))
|
|
|
500
612
|
|
|
501
613
|
__all__ = (
|
|
502
614
|
"AIOSQL_INSTALLED",
|
|
615
|
+
"ATTRS_INSTALLED",
|
|
616
|
+
"CATTRS_INSTALLED",
|
|
503
617
|
"FSSPEC_INSTALLED",
|
|
504
618
|
"LITESTAR_INSTALLED",
|
|
505
619
|
"MSGSPEC_INSTALLED",
|
|
@@ -510,6 +624,7 @@ __all__ = (
|
|
|
510
624
|
"PYARROW_INSTALLED",
|
|
511
625
|
"PYDANTIC_INSTALLED",
|
|
512
626
|
"UNSET",
|
|
627
|
+
"UNSET_STUB",
|
|
513
628
|
"AiosqlAsyncProtocol",
|
|
514
629
|
"AiosqlParamType",
|
|
515
630
|
"AiosqlProtocol",
|
|
@@ -519,26 +634,47 @@ __all__ = (
|
|
|
519
634
|
"ArrowRecordBatchResult",
|
|
520
635
|
"ArrowTable",
|
|
521
636
|
"ArrowTableResult",
|
|
637
|
+
"AttrsInstance",
|
|
638
|
+
"AttrsInstanceStub",
|
|
522
639
|
"BaseModel",
|
|
640
|
+
"BaseModelStub",
|
|
523
641
|
"Counter",
|
|
524
642
|
"DTOData",
|
|
643
|
+
"DTODataStub",
|
|
525
644
|
"DataclassProtocol",
|
|
526
645
|
"Empty",
|
|
527
646
|
"EmptyEnum",
|
|
528
647
|
"EmptyType",
|
|
529
648
|
"FailFast",
|
|
649
|
+
"FailFastStub",
|
|
530
650
|
"Gauge",
|
|
531
651
|
"Histogram",
|
|
532
652
|
"Span",
|
|
533
653
|
"Status",
|
|
534
654
|
"StatusCode",
|
|
535
655
|
"Struct",
|
|
656
|
+
"StructStub",
|
|
536
657
|
"T",
|
|
537
658
|
"T_co",
|
|
538
659
|
"Tracer",
|
|
539
660
|
"TypeAdapter",
|
|
661
|
+
"TypeAdapterStub",
|
|
540
662
|
"UnsetType",
|
|
663
|
+
"UnsetTypeStub",
|
|
541
664
|
"aiosql",
|
|
665
|
+
"attrs_asdict",
|
|
666
|
+
"attrs_asdict_stub",
|
|
667
|
+
"attrs_define",
|
|
668
|
+
"attrs_define_stub",
|
|
669
|
+
"attrs_field",
|
|
670
|
+
"attrs_field_stub",
|
|
671
|
+
"attrs_fields",
|
|
672
|
+
"attrs_fields_stub",
|
|
673
|
+
"attrs_has",
|
|
674
|
+
"attrs_has_stub",
|
|
675
|
+
"cattrs_structure",
|
|
676
|
+
"cattrs_unstructure",
|
|
542
677
|
"convert",
|
|
678
|
+
"convert_stub",
|
|
543
679
|
"trace",
|
|
544
680
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from sqlspec.adapters.adbc.
|
|
2
|
-
from sqlspec.adapters.adbc.
|
|
1
|
+
from sqlspec.adapters.adbc._types import AdbcConnection
|
|
2
|
+
from sqlspec.adapters.adbc.config import AdbcConfig, AdbcConnectionParams
|
|
3
|
+
from sqlspec.adapters.adbc.driver import AdbcCursor, AdbcDriver, AdbcExceptionHandler
|
|
3
4
|
|
|
4
|
-
__all__ = ("
|
|
5
|
+
__all__ = ("AdbcConfig", "AdbcConnection", "AdbcConnectionParams", "AdbcCursor", "AdbcDriver", "AdbcExceptionHandler")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# pyright: reportCallIssue=false, reportAttributeAccessIssue=false, reportArgumentType=false
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
from adbc_driver_manager.dbapi import Connection
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from typing_extensions import TypeAlias
|
|
8
|
+
|
|
9
|
+
AdbcConnection: TypeAlias = Connection
|
|
10
|
+
else:
|
|
11
|
+
AdbcConnection = Connection
|
|
12
|
+
__all__ = ("AdbcConnection",)
|