FastSQLA 0.4.5__tar.gz → 0.5.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: FastSQLA
3
- Version: 0.4.5
3
+ Version: 0.5.0
4
4
  Summary: SQLAlchemy extension for FastAPI that supports asynchronous sessions and includes built-in pagination.
5
5
  Author-email: Hadrien David <h@driendavid.com>
6
6
  Project-URL: Homepage, https://github.com/hadrien/fastsqla
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "FastSQLA"
3
- version = "0.4.5"
3
+ version = "0.5.0"
4
4
  description = "SQLAlchemy extension for FastAPI that supports asynchronous sessions and includes built-in pagination."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -39,8 +39,10 @@ Documentation = "https://github.com/hadrien/fastsqla"
39
39
  Repository = "https://github.com/hadrien/fastsqla"
40
40
  Issues = "https://github.com/hadrien/fastsqla/issues"
41
41
  Changelog = "https://github.com/hadrien/fastsqla/releases"
42
+
42
43
  [tool.setuptools]
43
44
  license-files = []
45
+
44
46
  [project.optional-dependencies]
45
47
  docs = [
46
48
  "mkdocs-glightbox>=0.4.0",
@@ -68,6 +70,7 @@ dev = [
68
70
  "aiosqlite>=0.20.0",
69
71
  "python-semantic-release>=9.8.8",
70
72
  "twine>=5.1.1",
73
+ "pdbpp>=0.11.7",
71
74
  ]
72
75
 
73
76
  [tool.uv.sources]
@@ -91,19 +94,33 @@ env = "GH_TOKEN"
91
94
  version_toml = ["pyproject.toml:project.version"]
92
95
  allow_zero_version = true
93
96
 
97
+ [tool.semantic_release.changelog]
98
+ mode = "init"
99
+
94
100
  [tool.semantic_release.changelog.default_templates]
95
101
  changelog_file = "./docs/changelog.md"
96
102
 
97
103
  [tool.tox]
98
- legacy_tox_ini = """
99
- [tox]
100
- envlist = { default, sqlmodel }
101
-
102
- [testenv]
103
- passenv = CI
104
- runner = uv-venv-lock-runner
105
- commands =
106
- pytest --cov fastsqla --cov-report=term-missing --cov-report=xml
107
- extras:
108
- sqlmodel: sqlmodel
109
- """
104
+ envlist = ["sqlmodel", "fastapi-pre121", "fastapi-post121"]
105
+
106
+ [tool.tox.env_run_base]
107
+ runner = "uv-venv-runner"
108
+ commands = [
109
+ [
110
+ "pytest",
111
+ "--cov",
112
+ "fastsqla",
113
+ "--cov-report=term-missing",
114
+ "--cov-report=xml",
115
+ ],
116
+ ]
117
+ allowlist_externals = ["pytest", "pip"]
118
+
119
+ [tool.tox.env.sqlmodel]
120
+ extras = ["sqlmodel"]
121
+
122
+ [tool.tox.env.fastapi-pre121]
123
+ commands_pre = [["pip", "install", "-U", "fastapi<0.121"]]
124
+
125
+ [tool.tox.env.fastapi-post121]
126
+ commands_pre = [["pip", "install", "-U", "fastapi>=0.121"]]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: FastSQLA
3
- Version: 0.4.5
3
+ Version: 0.5.0
4
4
  Summary: SQLAlchemy extension for FastAPI that supports asynchronous sessions and includes built-in pagination.
5
5
  Author-email: Hadrien David <h@driendavid.com>
6
6
  Project-URL: Homepage, https://github.com/hadrien/fastsqla
@@ -4,7 +4,8 @@ from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable
4
4
  from contextlib import _AsyncGeneratorContextManager, asynccontextmanager
5
5
  from typing import Annotated, Generic, TypeVar, TypedDict
6
6
 
7
- from fastapi import Depends, FastAPI, Query
7
+ from fastapi import Depends as BaseDepends
8
+ from fastapi import FastAPI, Query
8
9
  from pydantic import BaseModel, Field
9
10
  from sqlalchemy import Result, Select, func, select
10
11
  from sqlalchemy.ext.asyncio import (
@@ -44,6 +45,15 @@ SessionFactory = async_sessionmaker(expire_on_commit=False, class_=AsyncSession)
44
45
  logger = get_logger(__name__)
45
46
 
46
47
 
48
+ def Depends(*args, **kwargs):
49
+ "Allow backward compatibility with fastapi<0.121"
50
+ try:
51
+ return BaseDepends(*args, **kwargs)
52
+ except TypeError:
53
+ kwargs.pop("scope")
54
+ return BaseDepends(*args, **kwargs)
55
+
56
+
47
57
  class Base(DeclarativeBase, DeferredReflection):
48
58
  """Inherit from `Base` to declare an `SQLAlchemy` model.
49
59
 
@@ -252,7 +262,7 @@ async def new_session() -> AsyncGenerator[AsyncSession, None]:
252
262
  yield session
253
263
 
254
264
 
255
- Session = Annotated[AsyncSession, Depends(new_session)]
265
+ Session = Annotated[AsyncSession, Depends(new_session, scope="function")]
256
266
  """Dependency used exclusively in endpoints to get an `SQLAlchemy` or `SQLModel` session.
257
267
 
258
268
  `Session` is a [`FastAPI` dependency](https://fastapi.tiangolo.com/tutorial/dependencies/)
File without changes
File without changes