Skip to content

Commit 00c2f84

Browse files
authored
fix(storage): ensure streams are buffered (#344)
Ensure files are not fully read into memory while streaming.
1 parent bf4f2fe commit 00c2f84

35 files changed

Lines changed: 661 additions & 463 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ specs/
6161
.playwright-mcp
6262
.geminiignore
6363
uv.toml
64+
.beads/
65+
.agent/

.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.14.13"
20+
rev: "v0.14.14"
2121
hooks:
2222
- id: ruff
2323
args: ["--fix"]

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ maintainers = [{ name = "Litestar Developers", email = "hello@litestar.dev" }]
2424
name = "sqlspec"
2525
readme = "README.md"
2626
requires-python = ">=3.10, <4.0"
27-
version = "0.38.3"
27+
version = "0.38.4"
2828

2929
[project.urls]
3030
Discord = "https://discord.gg/litestar"
@@ -240,7 +240,7 @@ opt_level = "3" # Maximum optimization (0-3)
240240
allow_dirty = true
241241
commit = false
242242
commit_args = "--no-verify"
243-
current_version = "0.38.3"
243+
current_version = "0.38.4"
244244
ignore_missing_files = false
245245
ignore_missing_version = false
246246
message = "chore(release): bump to v{new_version}"

sqlspec/_typing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from enum import Enum
88
from typing import Any, ClassVar, Final, Literal, Protocol, cast, runtime_checkable
99

10-
from typing_extensions import TypeVar, dataclass_transform
10+
from typing_extensions import Self, TypeVar, dataclass_transform
1111

1212
from sqlspec.utils.module_loader import dependency_flag, module_available
1313

@@ -502,8 +502,8 @@ def set_status(self, status: Any, description: "str | None" = None) -> None:
502502
def end(self, end_time: "int | None" = None) -> None:
503503
return None
504504

505-
def __enter__(self) -> "Span":
506-
return self # type: ignore[return-value]
505+
def __enter__(self) -> Self:
506+
return self
507507

508508
def __exit__(self, exc_type: object, exc_val: object, exc_tb: object) -> None:
509509
return None

sqlspec/adapters/adbc/driver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import contextlib
88
from typing import TYPE_CHECKING, Any, Literal, cast
99

10+
from typing_extensions import Self
11+
1012
from sqlspec.adapters.adbc._typing import AdbcSessionContext
1113
from sqlspec.adapters.adbc.core import (
1214
collect_rows,
@@ -83,7 +85,7 @@ class AdbcExceptionHandler:
8385
def __init__(self) -> None:
8486
self.pending_exception: Exception | None = None
8587

86-
def __enter__(self) -> "AdbcExceptionHandler":
88+
def __enter__(self) -> Self:
8789
return self
8890

8991
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:

sqlspec/adapters/aiosqlite/driver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from sqlspec.driver import ExecutionResult
3131
from sqlspec.storage import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
3232

33+
from typing_extensions import Self
34+
3335
from sqlspec.adapters.aiosqlite._typing import AiosqliteSessionContext
3436

3537
__all__ = ("AiosqliteCursor", "AiosqliteDriver", "AiosqliteExceptionHandler", "AiosqliteSessionContext")
@@ -81,7 +83,7 @@ class AiosqliteExceptionHandler:
8183
def __init__(self) -> None:
8284
self.pending_exception: Exception | None = None
8385

84-
async def __aenter__(self) -> "AiosqliteExceptionHandler":
86+
async def __aenter__(self) -> Self:
8587
return self
8688

8789
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:

sqlspec/adapters/asyncmy/driver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
from sqlspec.driver import ExecutionResult
4040
from sqlspec.storage import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
4141

42+
from typing_extensions import Self
43+
4244
from sqlspec.adapters.asyncmy._typing import AsyncmySessionContext
4345

4446
__all__ = ("AsyncmyCursor", "AsyncmyDriver", "AsyncmyExceptionHandler", "AsyncmySessionContext")
@@ -88,7 +90,7 @@ class AsyncmyExceptionHandler:
8890
def __init__(self) -> None:
8991
self.pending_exception: Exception | None = None
9092

91-
async def __aenter__(self) -> "AsyncmyExceptionHandler":
93+
async def __aenter__(self) -> Self:
9294
return self
9395

9496
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:

sqlspec/adapters/asyncpg/driver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
from sqlspec.driver import ExecutionResult
4141
from sqlspec.storage import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
4242

43+
from typing_extensions import Self
44+
4345
from sqlspec.adapters.asyncpg._typing import AsyncpgSessionContext
4446

4547
__all__ = ("AsyncpgCursor", "AsyncpgDriver", "AsyncpgExceptionHandler", "AsyncpgSessionContext")
@@ -77,7 +79,7 @@ class AsyncpgExceptionHandler:
7779
def __init__(self) -> None:
7880
self.pending_exception: Exception | None = None
7981

80-
async def __aenter__(self) -> "AsyncpgExceptionHandler":
82+
async def __aenter__(self) -> Self:
8183
return self
8284

8385
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:

sqlspec/adapters/bigquery/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class BigQueryExceptionHandler:
106106
def __init__(self) -> None:
107107
self.pending_exception: Exception | None = None
108108

109-
def __enter__(self) -> "BigQueryExceptionHandler":
109+
def __enter__(self) -> "Self":
110110
return self
111111

112112
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:

sqlspec/adapters/cockroach_asyncpg/driver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import TYPE_CHECKING, Any, cast
66

77
import asyncpg
8+
from typing_extensions import Self
89

910
from sqlspec.adapters.asyncpg.core import create_mapped_exception, driver_profile
1011
from sqlspec.adapters.asyncpg.driver import AsyncpgDriver
@@ -40,7 +41,7 @@ class CockroachAsyncpgExceptionHandler:
4041
def __init__(self) -> None:
4142
self.pending_exception: Exception | None = None
4243

43-
async def __aenter__(self) -> "CockroachAsyncpgExceptionHandler":
44+
async def __aenter__(self) -> Self:
4445
return self
4546

4647
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:

0 commit comments

Comments
 (0)