Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.15.7"
rev: "v0.15.9"
hooks:
- id: ruff
args: ["--fix"]
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
]

autosummary_generate = False
smartquotes = False


autosectionlabel_prefix_document = True
Expand Down
20 changes: 5 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ uuid = ["uuid-utils"]

[dependency-groups]
benchmarks = ["sqlalchemy[asyncio]", "psutil", "types-psutil", "duckdb-engine>=0.17.0"]
build = ["bump-my-version", "hatch-mypyc", "pydantic-settings"]
build = ["bump-my-version", "hatch-mypyc", "mypy>=1.19.1", "pydantic-settings"]
dev = [
{ include-group = "extras" },
{ include-group = "lint" },
Expand Down Expand Up @@ -115,7 +115,7 @@ extras = [
"dishka",
]
lint = [
"mypy>=1.13.0",
"mypy>=1.19.1",
"pre-commit>=3.5.0",
"pyright>=1.1.386",
"ruff>=0.7.1",
Expand Down Expand Up @@ -176,7 +176,7 @@ packages = ["sqlspec"]


[tool.hatch.build.targets.wheel.hooks.mypyc]
dependencies = ["hatch-mypyc", "hatch-cython"]
dependencies = ["hatch-mypyc", "hatch-cython", "mypy>=1.19.1"]
enable-by-default = false
exclude = [
"tests/**", # Test files
Expand All @@ -187,21 +187,17 @@ exclude = [
"sqlspec/**/_typing.py", # Type aliases (mypyc-incompatible)
"sqlspec/config.py", # Main config
"sqlspec/extensions/**", # All extensions
"sqlspec/dialects/**/*.py", # Keep SQLGlot dialect subclasses interpreted
"sqlspec/**/__init__.py", # Init files (usually just imports)
"sqlspec/protocols.py", # Protocol definitions
"sqlspec/adapters/mock/**", # Mock adapter (testing only)
"sqlspec/migrations/commands.py", # Migration command CLI (dynamic imports)
"sqlspec/data_dictionary/_loader.py", # Loader relies on __file__ which fails in compiled modules
"sqlspec/dialects/postgres/_pgvector.py", # Dialect shell patches compiled sqlglot parser/generator registries
"sqlspec/dialects/postgres/_paradedb.py", # Dialect shell patches compiled sqlglot parser/generator registries
"sqlspec/dialects/spanner/_spanner.py", # Dialect shell patches compiled sqlglot parser hooks and post-processes DDL
"sqlspec/dialects/spanner/_spangres.py", # Dialect shell patches compiled sqlglot parser hooks
"sqlspec/extensions/fastapi/providers.py", # Uses SingletonMeta metaclass
"sqlspec/extensions/litestar/providers.py", # Uses SingletonMeta metaclass
"sqlspec/adapters/**/data_dictionary.py", # Cross-module inheritance causes mypyc segfaults
"sqlspec/observability/_formatting.py", # Inherits from non-compiled logging.Formatter
"sqlspec/utils/arrow_helpers.py", # Arrow operations cause segfaults when compiled
"sqlspec/storage/backends/_iterators.py", # Async __anext__ + asyncio.to_thread causes mypyc segfault
]
include = [
"sqlspec/core/**/*.py", # Core module
Expand All @@ -212,7 +208,7 @@ include = [
"sqlspec/driver/**/*.py", # Driver module
"sqlspec/storage/registry.py", # Safe storage registry/runtime routing
"sqlspec/storage/errors.py", # Safe storage error normalization
"sqlspec/storage/backends/base.py", # Storage backend runtime base classes (iterators in _iterators.py)
"sqlspec/storage/backends/base.py", # Storage backend runtime base classes
"sqlspec/data_dictionary/**/*.py", # Data dictionary mixin (required for adapter inheritance)
"sqlspec/adapters/**/core.py", # Adapter compiled helpers
"sqlspec/adapters/**/type_converter.py", # All adapters type converters
Expand Down Expand Up @@ -409,11 +405,7 @@ warn_unused_ignores = true
ignore_missing_imports = true
module = [
"orjson",
"re2",
"re2.*",
"uvicorn.*",
"googleapiclient",
"googleapiclient.*",
"uvloop.*",
"asyncmy",
"asyncmy.*",
Expand All @@ -428,8 +420,6 @@ module = [
"fsspec.*",
"sqlglot",
"sqlglot.*",
"pgvector",
"pgvector.*",
"minio",
]

Expand Down
12 changes: 10 additions & 2 deletions sqlspec/adapters/adbc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from sqlspec.adapters.adbc._typing import AdbcConnection
from sqlspec.adapters.adbc.config import AdbcConfig, AdbcConnectionParams
from sqlspec.adapters.adbc.config import AdbcConfig, AdbcConnectionParams, AdbcDriverFeatures
from sqlspec.adapters.adbc.driver import AdbcCursor, AdbcDriver, AdbcExceptionHandler

__all__ = ("AdbcConfig", "AdbcConnection", "AdbcConnectionParams", "AdbcCursor", "AdbcDriver", "AdbcExceptionHandler")
__all__ = (
"AdbcConfig",
"AdbcConnection",
"AdbcConnectionParams",
"AdbcCursor",
"AdbcDriver",
"AdbcDriverFeatures",
"AdbcExceptionHandler",
)
8 changes: 8 additions & 0 deletions sqlspec/adapters/adbc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ class AdbcConfig(NoPoolSyncConfig[AdbcConnection, AdbcDriver]):

Supports multiple database backends including PostgreSQL, SQLite, DuckDB,
BigQuery, and Snowflake with automatic driver detection and loading.

Example::

config = AdbcConfig(
connection_config=AdbcConnectionParams(
uri="postgresql://user:pass@localhost/db"
)
)
"""

driver_type: ClassVar[type[AdbcDriver]] = AdbcDriver
Expand Down
9 changes: 8 additions & 1 deletion sqlspec/adapters/aiosqlite/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ async def __aexit__(

@mypyc_attr(native_class=False)
class AiosqliteConfig(AsyncDatabaseConfig["AiosqliteConnection", AiosqliteConnectionPool, AiosqliteDriver]):
"""Database configuration for AioSQLite engine."""
"""Database configuration for AioSQLite engine.

Example::

config = AiosqliteConfig(
connection_config=AiosqlitePoolParams(database="app.db")
)
"""

driver_type: "ClassVar[type[AiosqliteDriver]]" = AiosqliteDriver
connection_type: "ClassVar[type[AiosqliteConnection]]" = AiosqliteConnection
Expand Down
11 changes: 10 additions & 1 deletion sqlspec/adapters/asyncmy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ async def __aexit__(

@mypyc_attr(native_class=False)
class AsyncmyConfig(AsyncDatabaseConfig[AsyncmyConnection, "AsyncmyPool", AsyncmyDriver]): # pyright: ignore
"""Configuration for Asyncmy database connections."""
"""Configuration for Asyncmy database connections.

Example::

config = AsyncmyConfig(
connection_config=AsyncmyPoolParams(
host="localhost", user="root", database="mydb"
)
)
"""

driver_type: ClassVar[type[AsyncmyDriver]] = AsyncmyDriver
connection_type: "ClassVar[type[Any]]" = cast("type[Any]", AsyncmyConnection)
Expand Down
4 changes: 2 additions & 2 deletions sqlspec/adapters/asyncmy/events/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from typing import Final

from sqlspec.adapters.asyncmy import AsyncmyConfig
from sqlspec.adapters.asyncmy.config import AsyncmyConfig
from sqlspec.extensions.events import BaseEventQueueStore

__all__ = ("AsyncmyEventQueueStore",)
Expand All @@ -32,7 +32,7 @@ class AsyncmyEventQueueStore(BaseEventQueueStore[AsyncmyConfig]):
- queue_table: Table name (default: "sqlspec_event_queue")

Example:
from sqlspec.adapters.asyncmy import AsyncmyConfig
from sqlspec.adapters.asyncmy.config import AsyncmyConfig
from sqlspec.adapters.asyncmy.events import AsyncmyEventQueueStore

config = AsyncmyConfig(
Expand Down
8 changes: 7 additions & 1 deletion sqlspec/adapters/asyncpg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
"""AsyncPG adapter for SQLSpec."""

from sqlspec.adapters.asyncpg._typing import AsyncpgConnection, AsyncpgCursor, AsyncpgPool, AsyncpgPreparedStatement
from sqlspec.adapters.asyncpg.config import AsyncpgConfig, AsyncpgConnectionConfig, AsyncpgPoolConfig
from sqlspec.adapters.asyncpg.config import (
AsyncpgConfig,
AsyncpgConnectionConfig,
AsyncpgDriverFeatures,
AsyncpgPoolConfig,
)
from sqlspec.adapters.asyncpg.core import default_statement_config
from sqlspec.adapters.asyncpg.driver import AsyncpgDriver, AsyncpgExceptionHandler
from sqlspec.dialects import postgres # noqa: F401
Expand All @@ -12,6 +17,7 @@
"AsyncpgConnectionConfig",
"AsyncpgCursor",
"AsyncpgDriver",
"AsyncpgDriverFeatures",
"AsyncpgExceptionHandler",
"AsyncpgPool",
"AsyncpgPoolConfig",
Expand Down
11 changes: 10 additions & 1 deletion sqlspec/adapters/asyncpg/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,16 @@ class AsyncpgConnectionContext(AsyncPoolConnectionContext):

@mypyc_attr(native_class=False)
class AsyncpgConfig(AsyncDatabaseConfig[AsyncpgConnection, "Pool[Record]", AsyncpgDriver]):
"""Configuration for AsyncPG database connections using TypedDict."""
"""Configuration for AsyncPG database connections using TypedDict.

Example::

config = AsyncpgConfig(
connection_config=AsyncpgPoolConfig(
dsn="postgresql://user:pass@localhost/db"
)
)
"""

driver_type: "ClassVar[type[AsyncpgDriver]]" = AsyncpgDriver
connection_type: "ClassVar[type[AsyncpgConnection]]" = type(AsyncpgConnection) # type: ignore[assignment]
Expand Down
3 changes: 2 additions & 1 deletion sqlspec/adapters/bigquery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sqlspec.adapters.bigquery._typing import BigQueryConnection, BigQueryCursor
from sqlspec.adapters.bigquery.config import BigQueryConfig, BigQueryConnectionParams
from sqlspec.adapters.bigquery.config import BigQueryConfig, BigQueryConnectionParams, BigQueryDriverFeatures
from sqlspec.adapters.bigquery.core import default_statement_config
from sqlspec.adapters.bigquery.driver import BigQueryDriver, BigQueryExceptionHandler

Expand All @@ -9,6 +9,7 @@
"BigQueryConnectionParams",
"BigQueryCursor",
"BigQueryDriver",
"BigQueryDriverFeatures",
"BigQueryExceptionHandler",
"default_statement_config",
)
8 changes: 8 additions & 0 deletions sqlspec/adapters/bigquery/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ class BigQueryConfig(NoPoolSyncConfig[BigQueryConnection, BigQueryDriver]):
"""BigQuery configuration.

Configuration for Google Cloud BigQuery connections.

Example::

config = BigQueryConfig(
connection_config=BigQueryConnectionParams(
project="my-gcp-project"
)
)
"""

driver_type: ClassVar[type[BigQueryDriver]] = BigQueryDriver
Expand Down
4 changes: 4 additions & 0 deletions sqlspec/adapters/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from sqlspec.adapters.duckdb.config import (
DuckDBConfig,
DuckDBConnectionParams,
DuckDBDriverFeatures,
DuckDBExtensionConfig,
DuckDBPoolParams,
DuckDBSecretConfig,
)
from sqlspec.adapters.duckdb.core import default_statement_config
Expand All @@ -18,8 +20,10 @@
"DuckDBConnectionPool",
"DuckDBCursor",
"DuckDBDriver",
"DuckDBDriverFeatures",
"DuckDBExceptionHandler",
"DuckDBExtensionConfig",
"DuckDBPoolParams",
"DuckDBSecretConfig",
"default_statement_config",
)
2 changes: 2 additions & 0 deletions sqlspec/adapters/oracledb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from sqlspec.adapters.oracledb.config import (
OracleAsyncConfig,
OracleConnectionParams,
OracleDriverFeatures,
OraclePoolParams,
OracleSyncConfig,
)
Expand All @@ -42,6 +43,7 @@
"OracleAsyncDriver",
"OracleAsyncExceptionHandler",
"OracleConnectionParams",
"OracleDriverFeatures",
"OraclePoolParams",
"OracleSyncConfig",
"OracleSyncConnection",
Expand Down
26 changes: 24 additions & 2 deletions sqlspec/adapters/oracledb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,18 @@ def release_connection(self, _conn: "OracleSyncConnection", **kwargs: Any) -> No


class OracleSyncConfig(SyncDatabaseConfig[OracleSyncConnection, "OracleSyncConnectionPool", OracleSyncDriver]):
"""Configuration for Oracle synchronous database connections."""
"""Configuration for Oracle synchronous database connections.

Example::

config = OracleSyncConfig(
connection_config=OraclePoolParams(
dsn="localhost:1521/XEPDB1",
user="app",
password="secret",
)
)
"""

__slots__ = ("_user_connection_hook",)

Expand Down Expand Up @@ -338,7 +349,18 @@ class _OracleAsyncSessionConnectionHandler(AsyncPoolSessionFactory):

@mypyc_attr(native_class=False)
class OracleAsyncConfig(AsyncDatabaseConfig[OracleAsyncConnection, "OracleAsyncConnectionPool", OracleAsyncDriver]):
"""Configuration for Oracle asynchronous database connections."""
"""Configuration for Oracle asynchronous database connections.

Example::

config = OracleAsyncConfig(
connection_config=OraclePoolParams(
dsn="localhost:1521/XEPDB1",
user="app",
password="secret",
)
)
"""

__slots__ = ("_user_connection_hook",)

Expand Down
11 changes: 10 additions & 1 deletion sqlspec/adapters/psqlpy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,16 @@ async def __aexit__(

@mypyc_attr(native_class=False)
class PsqlpyConfig(AsyncDatabaseConfig[PsqlpyConnection, ConnectionPool, PsqlpyDriver]):
"""Configuration for Psqlpy asynchronous database connections."""
"""Configuration for Psqlpy asynchronous database connections.

Example::

config = PsqlpyConfig(
connection_config=PsqlpyPoolParams(
dsn="postgresql://user:pass@localhost/db"
)
)
"""

driver_type: ClassVar[type[PsqlpyDriver]] = PsqlpyDriver
connection_type: "ClassVar[type[PsqlpyConnection]]" = PsqlpyConnection
Expand Down
2 changes: 2 additions & 0 deletions sqlspec/adapters/psycopg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sqlspec.adapters.psycopg.config import (
PsycopgAsyncConfig,
PsycopgConnectionParams,
PsycopgDriverFeatures,
PsycopgPoolParams,
PsycopgSyncConfig,
)
Expand All @@ -26,6 +27,7 @@
"PsycopgAsyncDriver",
"PsycopgAsyncExceptionHandler",
"PsycopgConnectionParams",
"PsycopgDriverFeatures",
"PsycopgPoolParams",
"PsycopgSyncConfig",
"PsycopgSyncConnection",
Expand Down
6 changes: 6 additions & 0 deletions sqlspec/adapters/psycopg/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

from psycopg import AsyncConnection, AsyncCursor, Connection, Cursor
from psycopg.rows import DictRow as PsycopgDictRow
from psycopg.sql import SQL as PsycopgSQL # noqa: N811
from psycopg.sql import Composed as PsycopgComposed
from psycopg.sql import Identifier as PsycopgIdentifier

if TYPE_CHECKING:
from collections.abc import Callable
Expand Down Expand Up @@ -203,8 +206,11 @@ async def __aexit__(
"PsycopgAsyncCursor",
"PsycopgAsyncRawCursor",
"PsycopgAsyncSessionContext",
"PsycopgComposed",
"PsycopgDictRow",
"PsycopgIdentifier",
"PsycopgPipelineDriver",
"PsycopgSQL",
"PsycopgSyncConnection",
"PsycopgSyncCursor",
"PsycopgSyncRawCursor",
Expand Down
Loading
Loading