Skip to content

Commit e3c308b

Browse files
committed
feat: remove the drivers for now
1 parent ed60cfa commit e3c308b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+830
-3240
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: mixed-line-ending
1818
- id: trailing-whitespace
1919
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: "v0.8.0"
20+
rev: "v0.8.3"
2121
hooks:
2222
- id: ruff
2323
args: ["--fix"]

pyproject.toml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ asyncmy = ["asyncmy"]
1616
asyncpg = ["asyncpg"]
1717
bigquery = ["google-cloud-bigquery"]
1818
duckdb = ["duckdb"]
19+
fastapi = ["fastapi"]
20+
flask = ["flask"]
21+
litestar = ["litestar"]
1922
msgspec = ["msgspec"]
2023
oracledb = ["oracledb"]
2124
performance = ["sqlglot[rs]", "google-re2; sys_platform == \"linux\""]
@@ -24,12 +27,16 @@ pydantic = ["pydantic"]
2427
pymssql = ["pymssql"]
2528
pymysql = ["pymysql"]
2629
spanner = ["google-cloud-spanner"]
27-
litestar = ["litestar"]
28-
fastapi = ["fastapi"]
29-
flask = ["flask"]
3030

3131
[dependency-groups]
32-
dev = ["adbc-driver-sqlite", "adbc-driver-postgresql", "adbc-driver-flightsql", { include-group = "lint" }, { include-group = "doc" }, { include-group = "test" }]
32+
dev = [
33+
"adbc-driver-sqlite",
34+
"adbc-driver-postgresql",
35+
"adbc-driver-flightsql",
36+
{ include-group = "lint" },
37+
{ include-group = "doc" },
38+
{ include-group = "test" },
39+
]
3340
doc = [
3441
"auto-pytabs[sphinx]>=0.5.0",
3542
"git-cliff>=2.6.1",
@@ -45,7 +52,15 @@ doc = [
4552
"sphinx-togglebutton>=0.3.2",
4653
"sphinx-toolbox>=3.8.1",
4754
]
48-
lint = ["mypy>=1.13.0", "pre-commit>=3.5.0", "pyright>=1.1.386", "ruff>=0.7.1", "slotscheck>=0.16.5", "types-Pygments", "types-colorama"]
55+
lint = [
56+
"mypy>=1.13.0",
57+
"pre-commit>=3.5.0",
58+
"pyright>=1.1.386",
59+
"ruff>=0.7.1",
60+
"slotscheck>=0.16.5",
61+
"types-Pygments",
62+
"types-colorama",
63+
]
4964
test = [
5065
"anyio",
5166
"coverage>=7.6.1",
@@ -133,14 +148,7 @@ warn_unused_ignores = true
133148

134149
[[tool.mypy.overrides]]
135150
ignore_missing_imports = true
136-
module = [
137-
"orjson","re2",
138-
"re2.*",
139-
"uvicorn.*",
140-
"googleapiclient",
141-
"googleapiclient.*",
142-
"uvloop.*",
143-
]
151+
module = ["orjson", "re2", "re2.*", "uvicorn.*", "googleapiclient", "googleapiclient.*", "uvloop.*"]
144152

145153
[tool.pyright]
146154
disableBytesTypePromotions = true
@@ -184,7 +192,7 @@ lint.select = [
184192
"SIM", # flake8-simplify
185193
"T10", # flake8-debugger
186194
"T20", # flake8-print
187-
"TCH", # flake8-type-checking
195+
"TC", # flake8-type-checking
188196
"TID", # flake8-tidy-imports
189197
"UP", # pyupgrade
190198
"W", # pycodestyle - warning
@@ -227,7 +235,7 @@ classmethod-decorators = ["classmethod"]
227235
known-first-party = ["sqlspec", "tests"]
228236

229237
[tool.ruff.lint.per-file-ignores]
230-
"docs/**/*.*" = ["S", "B", "DTZ", "A", "TCH", "ERA", "D", "RET", "PLW0127"]
238+
"docs/**/*.*" = ["S", "B", "DTZ", "A", "TC", "ERA", "D", "RET", "PLW0127"]
231239
"docs/examples/**" = ["T201"]
232240
"tests/**/*.*" = [
233241
"A",
@@ -250,7 +258,7 @@ known-first-party = ["sqlspec", "tests"]
250258
"S",
251259
"S101",
252260
"SIM",
253-
"TCH",
261+
"TC",
254262
"TRY",
255263
]
256264
"tools/**/*.*" = ["D", "ARG", "EM", "TRY", "G", "FBT", "S603", "F811", "PLW0127"]

sqlspec/_serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def encode_json(data: Any) -> str:
1414
except ImportError:
1515
try:
1616
from orjson import dumps as _encode_json # pyright: ignore[reportMissingImports]
17-
from orjson import loads as decode_json # type: ignore[no-redef,assignment]
17+
from orjson import loads as decode_json # type: ignore[no-redef]
1818

1919
def encode_json(data: Any) -> str:
2020
return _encode_json(data).decode("utf-8") # type: ignore[no-any-return]

sqlspec/_typing.py

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
"""This is a simple wrapper around a few important classes in each library.
2+
3+
This is used to ensure compatibility when one or more of the libraries are installed.
4+
"""
5+
6+
from __future__ import annotations
7+
8+
from typing import (
9+
Any,
10+
ClassVar,
11+
Protocol,
12+
cast,
13+
runtime_checkable,
14+
)
15+
16+
from typing_extensions import TypeVar, dataclass_transform
17+
18+
T = TypeVar("T")
19+
T_co = TypeVar("T_co", covariant=True)
20+
21+
22+
try:
23+
from pydantic import BaseModel, FailFast, TypeAdapter
24+
25+
PYDANTIC_INSTALLED = True
26+
except ImportError:
27+
28+
@runtime_checkable
29+
class BaseModel(Protocol): # type: ignore[no-redef]
30+
"""Placeholder Implementation"""
31+
32+
model_fields: ClassVar[dict[str, Any]]
33+
34+
def model_dump(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
35+
"""Placeholder"""
36+
return {}
37+
38+
@runtime_checkable
39+
class TypeAdapter(Protocol[T_co]): # type: ignore[no-redef]
40+
"""Placeholder Implementation"""
41+
42+
def __init__(
43+
self,
44+
type: Any, # noqa: A002
45+
*,
46+
config: Any | None = None,
47+
_parent_depth: int = 2,
48+
module: str | None = None,
49+
) -> None:
50+
"""Init"""
51+
52+
def validate_python(
53+
self,
54+
object: Any, # noqa: A002
55+
/,
56+
*,
57+
strict: bool | None = None,
58+
from_attributes: bool | None = None,
59+
context: dict[str, Any] | None = None,
60+
) -> T_co:
61+
"""Stub"""
62+
return cast("T_co", object)
63+
64+
@runtime_checkable
65+
class FailFast(Protocol): # type: ignore[no-redef]
66+
"""Placeholder Implementation for FailFast"""
67+
68+
def __init__(self, *args: Any, **kwargs: Any) -> None:
69+
"""Init"""
70+
71+
PYDANTIC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
72+
73+
try:
74+
from msgspec import (
75+
UNSET,
76+
Struct,
77+
UnsetType, # pyright: ignore[reportAssignmentType]
78+
convert,
79+
)
80+
81+
MSGSPEC_INSTALLED: bool = True
82+
except ImportError:
83+
import enum
84+
85+
@dataclass_transform()
86+
@runtime_checkable
87+
class Struct(Protocol): # type: ignore[no-redef]
88+
"""Placeholder Implementation"""
89+
90+
__struct_fields__: ClassVar[tuple[str, ...]]
91+
92+
def convert(*args: Any, **kwargs: Any) -> Any: # type: ignore[no-redef]
93+
"""Placeholder implementation"""
94+
return {}
95+
96+
class UnsetType(enum.Enum): # type: ignore[no-redef]
97+
UNSET = "UNSET"
98+
99+
UNSET = UnsetType.UNSET # pyright: ignore[reportConstantRedefinition]
100+
MSGSPEC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
101+
102+
__all__ = (
103+
"MSGSPEC_INSTALLED",
104+
"PYDANTIC_INSTALLED",
105+
"UNSET",
106+
"BaseModel",
107+
"FailFast",
108+
"Struct",
109+
"TypeAdapter",
110+
"UnsetType",
111+
"convert",
112+
)

sqlspec/adapters/adbc/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
from dataclasses import dataclass
55
from typing import TYPE_CHECKING, TypeVar
66

7-
from sqlspec.types.configs import GenericDatabaseConfig
8-
from sqlspec.types.empty import Empty
7+
from sqlspec.config import GenericDatabaseConfig
8+
from sqlspec.utils.empty import Empty
99

1010
if TYPE_CHECKING:
1111
from collections.abc import Generator
1212
from typing import Any
1313

1414
from adbc_driver_manager.dbapi import Connection, Cursor
1515

16-
from sqlspec.types.empty import EmptyType
16+
from sqlspec.utils.empty import EmptyType
1717

1818
__all__ = ("AdbcDatabaseConfig",)
1919

sqlspec/adapters/adbc/driver.py

Lines changed: 0 additions & 142 deletions
This file was deleted.

sqlspec/adapters/aiosqlite/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from dataclasses import dataclass
55
from typing import TYPE_CHECKING, Any
66

7+
from sqlspec.config import GenericDatabaseConfig
78
from sqlspec.exceptions import ImproperConfigurationError
8-
from sqlspec.types.configs import GenericDatabaseConfig
9-
from sqlspec.types.empty import Empty, EmptyType
109
from sqlspec.utils.dataclass import simple_asdict
10+
from sqlspec.utils.empty import Empty, EmptyType
1111

1212
if TYPE_CHECKING:
1313
from collections.abc import AsyncGenerator

0 commit comments

Comments
 (0)