sqlspec 0.14.1__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.

Files changed (158) hide show
  1. sqlspec/__init__.py +50 -25
  2. sqlspec/__main__.py +1 -1
  3. sqlspec/__metadata__.py +1 -3
  4. sqlspec/_serialization.py +1 -2
  5. sqlspec/_sql.py +256 -120
  6. sqlspec/_typing.py +278 -142
  7. sqlspec/adapters/adbc/__init__.py +4 -3
  8. sqlspec/adapters/adbc/_types.py +12 -0
  9. sqlspec/adapters/adbc/config.py +115 -260
  10. sqlspec/adapters/adbc/driver.py +462 -367
  11. sqlspec/adapters/aiosqlite/__init__.py +18 -3
  12. sqlspec/adapters/aiosqlite/_types.py +13 -0
  13. sqlspec/adapters/aiosqlite/config.py +199 -129
  14. sqlspec/adapters/aiosqlite/driver.py +230 -269
  15. sqlspec/adapters/asyncmy/__init__.py +18 -3
  16. sqlspec/adapters/asyncmy/_types.py +12 -0
  17. sqlspec/adapters/asyncmy/config.py +80 -168
  18. sqlspec/adapters/asyncmy/driver.py +260 -225
  19. sqlspec/adapters/asyncpg/__init__.py +19 -4
  20. sqlspec/adapters/asyncpg/_types.py +17 -0
  21. sqlspec/adapters/asyncpg/config.py +82 -181
  22. sqlspec/adapters/asyncpg/driver.py +285 -383
  23. sqlspec/adapters/bigquery/__init__.py +17 -3
  24. sqlspec/adapters/bigquery/_types.py +12 -0
  25. sqlspec/adapters/bigquery/config.py +191 -258
  26. sqlspec/adapters/bigquery/driver.py +474 -646
  27. sqlspec/adapters/duckdb/__init__.py +14 -3
  28. sqlspec/adapters/duckdb/_types.py +12 -0
  29. sqlspec/adapters/duckdb/config.py +415 -351
  30. sqlspec/adapters/duckdb/driver.py +343 -413
  31. sqlspec/adapters/oracledb/__init__.py +19 -5
  32. sqlspec/adapters/oracledb/_types.py +14 -0
  33. sqlspec/adapters/oracledb/config.py +123 -379
  34. sqlspec/adapters/oracledb/driver.py +507 -560
  35. sqlspec/adapters/psqlpy/__init__.py +13 -3
  36. sqlspec/adapters/psqlpy/_types.py +11 -0
  37. sqlspec/adapters/psqlpy/config.py +93 -254
  38. sqlspec/adapters/psqlpy/driver.py +505 -234
  39. sqlspec/adapters/psycopg/__init__.py +19 -5
  40. sqlspec/adapters/psycopg/_types.py +17 -0
  41. sqlspec/adapters/psycopg/config.py +143 -403
  42. sqlspec/adapters/psycopg/driver.py +706 -872
  43. sqlspec/adapters/sqlite/__init__.py +14 -3
  44. sqlspec/adapters/sqlite/_types.py +11 -0
  45. sqlspec/adapters/sqlite/config.py +202 -118
  46. sqlspec/adapters/sqlite/driver.py +264 -303
  47. sqlspec/base.py +105 -9
  48. sqlspec/{statement/builder → builder}/__init__.py +12 -14
  49. sqlspec/{statement/builder → builder}/_base.py +120 -55
  50. sqlspec/{statement/builder → builder}/_column.py +17 -6
  51. sqlspec/{statement/builder → builder}/_ddl.py +46 -79
  52. sqlspec/{statement/builder → builder}/_ddl_utils.py +5 -10
  53. sqlspec/{statement/builder → builder}/_delete.py +6 -25
  54. sqlspec/{statement/builder → builder}/_insert.py +6 -64
  55. sqlspec/builder/_merge.py +56 -0
  56. sqlspec/{statement/builder → builder}/_parsing_utils.py +3 -10
  57. sqlspec/{statement/builder → builder}/_select.py +11 -56
  58. sqlspec/{statement/builder → builder}/_update.py +12 -18
  59. sqlspec/{statement/builder → builder}/mixins/__init__.py +10 -14
  60. sqlspec/{statement/builder → builder}/mixins/_cte_and_set_ops.py +48 -59
  61. sqlspec/{statement/builder → builder}/mixins/_insert_operations.py +22 -16
  62. sqlspec/{statement/builder → builder}/mixins/_join_operations.py +1 -3
  63. sqlspec/{statement/builder → builder}/mixins/_merge_operations.py +3 -5
  64. sqlspec/{statement/builder → builder}/mixins/_order_limit_operations.py +3 -3
  65. sqlspec/{statement/builder → builder}/mixins/_pivot_operations.py +4 -8
  66. sqlspec/{statement/builder → builder}/mixins/_select_operations.py +21 -36
  67. sqlspec/{statement/builder → builder}/mixins/_update_operations.py +3 -14
  68. sqlspec/{statement/builder → builder}/mixins/_where_clause.py +52 -79
  69. sqlspec/cli.py +4 -5
  70. sqlspec/config.py +180 -133
  71. sqlspec/core/__init__.py +63 -0
  72. sqlspec/core/cache.py +873 -0
  73. sqlspec/core/compiler.py +396 -0
  74. sqlspec/core/filters.py +828 -0
  75. sqlspec/core/hashing.py +310 -0
  76. sqlspec/core/parameters.py +1209 -0
  77. sqlspec/core/result.py +664 -0
  78. sqlspec/{statement → core}/splitter.py +321 -191
  79. sqlspec/core/statement.py +651 -0
  80. sqlspec/driver/__init__.py +7 -10
  81. sqlspec/driver/_async.py +387 -176
  82. sqlspec/driver/_common.py +527 -289
  83. sqlspec/driver/_sync.py +390 -172
  84. sqlspec/driver/mixins/__init__.py +2 -19
  85. sqlspec/driver/mixins/_result_tools.py +168 -0
  86. sqlspec/driver/mixins/_sql_translator.py +6 -3
  87. sqlspec/exceptions.py +5 -252
  88. sqlspec/extensions/aiosql/adapter.py +93 -96
  89. sqlspec/extensions/litestar/config.py +0 -1
  90. sqlspec/extensions/litestar/handlers.py +15 -26
  91. sqlspec/extensions/litestar/plugin.py +16 -14
  92. sqlspec/extensions/litestar/providers.py +17 -52
  93. sqlspec/loader.py +424 -105
  94. sqlspec/migrations/__init__.py +12 -0
  95. sqlspec/migrations/base.py +92 -68
  96. sqlspec/migrations/commands.py +24 -106
  97. sqlspec/migrations/loaders.py +402 -0
  98. sqlspec/migrations/runner.py +49 -51
  99. sqlspec/migrations/tracker.py +31 -44
  100. sqlspec/migrations/utils.py +64 -24
  101. sqlspec/protocols.py +7 -183
  102. sqlspec/storage/__init__.py +1 -1
  103. sqlspec/storage/backends/base.py +37 -40
  104. sqlspec/storage/backends/fsspec.py +136 -112
  105. sqlspec/storage/backends/obstore.py +138 -160
  106. sqlspec/storage/capabilities.py +5 -4
  107. sqlspec/storage/registry.py +57 -106
  108. sqlspec/typing.py +136 -115
  109. sqlspec/utils/__init__.py +2 -3
  110. sqlspec/utils/correlation.py +0 -3
  111. sqlspec/utils/deprecation.py +6 -6
  112. sqlspec/utils/fixtures.py +6 -6
  113. sqlspec/utils/logging.py +0 -2
  114. sqlspec/utils/module_loader.py +7 -12
  115. sqlspec/utils/singleton.py +0 -1
  116. sqlspec/utils/sync_tools.py +16 -37
  117. sqlspec/utils/text.py +12 -51
  118. sqlspec/utils/type_guards.py +443 -232
  119. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/METADATA +7 -2
  120. sqlspec-0.15.0.dist-info/RECORD +134 -0
  121. sqlspec/adapters/adbc/transformers.py +0 -108
  122. sqlspec/driver/connection.py +0 -207
  123. sqlspec/driver/mixins/_cache.py +0 -114
  124. sqlspec/driver/mixins/_csv_writer.py +0 -91
  125. sqlspec/driver/mixins/_pipeline.py +0 -508
  126. sqlspec/driver/mixins/_query_tools.py +0 -796
  127. sqlspec/driver/mixins/_result_utils.py +0 -138
  128. sqlspec/driver/mixins/_storage.py +0 -912
  129. sqlspec/driver/mixins/_type_coercion.py +0 -128
  130. sqlspec/driver/parameters.py +0 -138
  131. sqlspec/statement/__init__.py +0 -21
  132. sqlspec/statement/builder/_merge.py +0 -95
  133. sqlspec/statement/cache.py +0 -50
  134. sqlspec/statement/filters.py +0 -625
  135. sqlspec/statement/parameters.py +0 -956
  136. sqlspec/statement/pipelines/__init__.py +0 -210
  137. sqlspec/statement/pipelines/analyzers/__init__.py +0 -9
  138. sqlspec/statement/pipelines/analyzers/_analyzer.py +0 -646
  139. sqlspec/statement/pipelines/context.py +0 -109
  140. sqlspec/statement/pipelines/transformers/__init__.py +0 -7
  141. sqlspec/statement/pipelines/transformers/_expression_simplifier.py +0 -88
  142. sqlspec/statement/pipelines/transformers/_literal_parameterizer.py +0 -1247
  143. sqlspec/statement/pipelines/transformers/_remove_comments_and_hints.py +0 -76
  144. sqlspec/statement/pipelines/validators/__init__.py +0 -23
  145. sqlspec/statement/pipelines/validators/_dml_safety.py +0 -290
  146. sqlspec/statement/pipelines/validators/_parameter_style.py +0 -370
  147. sqlspec/statement/pipelines/validators/_performance.py +0 -714
  148. sqlspec/statement/pipelines/validators/_security.py +0 -967
  149. sqlspec/statement/result.py +0 -435
  150. sqlspec/statement/sql.py +0 -1774
  151. sqlspec/utils/cached_property.py +0 -25
  152. sqlspec/utils/statement_hashing.py +0 -203
  153. sqlspec-0.14.1.dist-info/RECORD +0 -145
  154. /sqlspec/{statement/builder → builder}/mixins/_delete_operations.py +0 -0
  155. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/WHEEL +0 -0
  156. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/entry_points.txt +0 -0
  157. {sqlspec-0.14.1.dist-info → sqlspec-0.15.0.dist-info}/licenses/LICENSE +0 -0
  158. {sqlspec-0.14.1.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
- """This is a simple wrapper around a few important classes in each library.
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
- try:
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
- class BaseModel(Protocol): # type: ignore[no-redef]
41
- """Placeholder Implementation"""
27
+ class BaseModelStub:
28
+ """Placeholder implementation."""
42
29
 
43
- model_fields: "ClassVar[dict[str, Any]]"
30
+ model_fields: ClassVar[dict[str, Any]] = {}
31
+ __slots__ = ("__dict__", "__pydantic_extra__", "__pydantic_fields_set__", "__pydantic_private__")
44
32
 
45
- def model_dump(
46
- self,
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
- @runtime_checkable
82
- class TypeAdapter(Protocol[T_co]): # type: ignore[no-redef]
83
- """Placeholder Implementation"""
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
- def validate_python(
96
- self,
97
- object: Any,
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
- PYDANTIC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
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
- MSGSPEC_INSTALLED: bool = True
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
- import enum
127
- from collections.abc import Iterable
128
- from typing import Callable, Optional, Union
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
- @dataclass_transform()
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
- def convert( # type: ignore[no-redef]
138
- obj: Any,
139
- type: "Union[Any, type[T]]", # noqa: A002
140
- *,
141
- strict: bool = True,
142
- from_attributes: bool = False,
143
- dec_hook: "Optional[Callable[[type, Any], Any]]" = None,
144
- builtin_types: "Optional[Iterable[type]]" = None,
145
- str_keys: bool = False,
146
- ) -> "Union[T, Any]":
147
- """Placeholder implementation"""
148
- return {}
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
- UNSET = UnsetType.UNSET # pyright: ignore[reportConstantRedefinition]
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
- LITESTAR_INSTALLED = True
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
- __slots__ = ("_backend", "_data_as_builtins")
213
+ # Always define stub types for attrs
214
+ @dataclass_transform()
215
+ class AttrsInstanceStub:
216
+ """Placeholder Implementation for attrs classes"""
167
217
 
168
- def __init__(self, backend: Any, data_as_builtins: Any) -> None:
169
- """Placeholder init"""
218
+ __attrs_attrs__: ClassVar[tuple[Any, ...]] = ()
219
+ __slots__ = ()
170
220
 
171
- def create_instance(self, **kwargs: Any) -> T:
172
- return cast("T", kwargs)
221
+ def __init__(self, **kwargs: Any) -> None:
222
+ for key, value in kwargs.items():
223
+ setattr(self, key, value)
173
224
 
174
- def update_instance(self, instance: T, **kwargs: Any) -> T:
175
- """Placeholder implementation"""
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
- LITESTAR_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
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.config import CONNECTION_FIELDS, AdbcConfig
2
- from sqlspec.adapters.adbc.driver import AdbcConnection, AdbcDriver
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__ = ("CONNECTION_FIELDS", "AdbcConfig", "AdbcConnection", "AdbcDriver")
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",)