fastapi-sqla 3.1.1__tar.gz → 3.2.1__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.
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/PKG-INFO +6 -7
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/_pytest_plugin.py +1 -6
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/async_pagination.py +14 -14
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/aws_rds_iam_support.py +2 -1
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/base.py +0 -1
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/models.py +1 -1
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/pagination.py +22 -22
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/sqla.py +5 -8
- fastapi_sqla-3.2.1/pyproject.toml +220 -0
- fastapi_sqla-3.1.1/pyproject.toml +0 -132
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/LICENSE +0 -0
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/README.md +0 -0
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/__init__.py +0 -0
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/async_sqla.py +0 -0
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/aws_aurora_support.py +0 -0
- {fastapi_sqla-3.1.1 → fastapi_sqla-3.2.1}/fastapi_sqla/py.typed +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fastapi-sqla
|
|
3
|
-
Version: 3.
|
|
4
|
-
Summary: SQLAlchemy extension for FastAPI with support for pagination, asyncio, and pytest, ready for production.
|
|
3
|
+
Version: 3.2.1
|
|
4
|
+
Summary: SQLAlchemy extension for FastAPI with support for pagination, asyncio, SQLModel, and pytest, ready for production.
|
|
5
5
|
Home-page: https://github.com/dialoguemd/fastapi-sqla
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: FastAPI,SQLAlchemy,asyncio,pytest,alembic
|
|
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.9
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.10
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
26
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
26
27
|
Classifier: Programming Language :: SQL
|
|
27
28
|
Classifier: Topic :: Internet
|
|
@@ -40,20 +41,18 @@ Requires-Dist: Faker (>=14.2.0,<15.0.0) ; extra == "tests"
|
|
|
40
41
|
Requires-Dist: alembic (>=1.4.3,<2.0.0) ; extra == "tests"
|
|
41
42
|
Requires-Dist: asgi_lifespan (>=1.0.1,<2.0.0) ; extra == "tests"
|
|
42
43
|
Requires-Dist: asyncpg (>=0.28.0,<0.29.0) ; extra == "asyncpg"
|
|
43
|
-
Requires-Dist: black (>=22.8.0,<23.0.0) ; extra == "tests"
|
|
44
44
|
Requires-Dist: boto3 (>=1.24.74,<2.0.0) ; extra == "aws-rds-iam"
|
|
45
45
|
Requires-Dist: fastapi (>=0.95.1)
|
|
46
|
-
Requires-Dist: greenlet (>=
|
|
46
|
+
Requires-Dist: greenlet (>=3.0.3,<4.0.0) ; extra == "tests"
|
|
47
47
|
Requires-Dist: httpx (>=0.23.0,<0.24.0) ; extra == "tests"
|
|
48
|
-
Requires-Dist:
|
|
49
|
-
Requires-Dist: mypy[tests] (>=0.991,<0.992) ; extra == "tests"
|
|
48
|
+
Requires-Dist: mypy[tests] (>=1.0.0,<2.0.0) ; extra == "tests"
|
|
50
49
|
Requires-Dist: pdbpp (>=0.10.2,<0.11.0) ; extra == "tests"
|
|
51
50
|
Requires-Dist: psycopg2 (>=2.8.6,<3.0.0) ; extra == "tests"
|
|
52
51
|
Requires-Dist: pydantic (>=1)
|
|
53
|
-
Requires-Dist: pylama (>=8.4.1,<9.0.0) ; extra == "tests"
|
|
54
52
|
Requires-Dist: pytest (>=7.2.1,<8.0.0) ; extra == "tests"
|
|
55
53
|
Requires-Dist: pytest-asyncio (>=0.19.0,<0.20.0) ; extra == "tests"
|
|
56
54
|
Requires-Dist: pytest-cov (>=2.10.1,<3.0.0) ; extra == "tests"
|
|
55
|
+
Requires-Dist: ruff (>=0.4.5,<0.5.0) ; extra == "tests"
|
|
57
56
|
Requires-Dist: sqlalchemy (>=1.3)
|
|
58
57
|
Requires-Dist: sqlmodel (>=0.0.14,<0.0.15) ; extra == "sqlmodel"
|
|
59
58
|
Requires-Dist: structlog (>=20)
|
|
@@ -28,7 +28,6 @@ def db_host():
|
|
|
28
28
|
When CI key is set in environment variables, it uses `postgres` as host name else,
|
|
29
29
|
host used is `localhost`
|
|
30
30
|
"""
|
|
31
|
-
|
|
32
31
|
return "postgres" if "CI" in os.environ else "localhost"
|
|
33
32
|
|
|
34
33
|
|
|
@@ -38,7 +37,6 @@ def db_user():
|
|
|
38
37
|
|
|
39
38
|
postgres
|
|
40
39
|
"""
|
|
41
|
-
|
|
42
40
|
return "postgres"
|
|
43
41
|
|
|
44
42
|
|
|
@@ -48,7 +46,6 @@ def db_url(db_host, db_user):
|
|
|
48
46
|
|
|
49
47
|
db url example postgresql://{db_user}@{db_host}/postgres
|
|
50
48
|
"""
|
|
51
|
-
|
|
52
49
|
return f"postgresql://{db_user}@{db_host}/postgres"
|
|
53
50
|
|
|
54
51
|
|
|
@@ -107,7 +104,6 @@ def sqla_reflection(sqla_modules, sqla_connection):
|
|
|
107
104
|
@fixture
|
|
108
105
|
def patch_engine_from_config(request, sqla_connection):
|
|
109
106
|
"""So that all DB operations are never written to db for real."""
|
|
110
|
-
|
|
111
107
|
if "dont_patch_engines" in request.keywords:
|
|
112
108
|
yield
|
|
113
109
|
else:
|
|
@@ -153,7 +149,7 @@ def async_sqlalchemy_url(db_url):
|
|
|
153
149
|
return format_async_async_sqlalchemy_url(db_url)
|
|
154
150
|
|
|
155
151
|
|
|
156
|
-
if asyncio_support:
|
|
152
|
+
if asyncio_support:
|
|
157
153
|
|
|
158
154
|
@fixture
|
|
159
155
|
def async_engine(async_sqlalchemy_url):
|
|
@@ -167,7 +163,6 @@ if asyncio_support: # noqa: C901
|
|
|
167
163
|
@fixture
|
|
168
164
|
async def patch_new_engine(request, async_sqla_connection):
|
|
169
165
|
"""So that all async DB operations are never written to db for real."""
|
|
170
|
-
|
|
171
166
|
if "dont_patch_engines" in request.keywords:
|
|
172
167
|
yield
|
|
173
168
|
else:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import math
|
|
2
|
-
from collections.abc import Awaitable, Callable
|
|
3
|
-
from typing import Annotated,
|
|
2
|
+
from collections.abc import Awaitable, Callable, Iterator
|
|
3
|
+
from typing import Annotated, Optional, Union, cast
|
|
4
4
|
|
|
5
5
|
from fastapi import Depends, Query
|
|
6
6
|
from sqlalchemy.sql import Select, func, select
|
|
7
7
|
|
|
8
8
|
from fastapi_sqla.async_sqla import AsyncSessionDependency, SqlaAsyncSession
|
|
9
|
-
from fastapi_sqla.models import Page
|
|
9
|
+
from fastapi_sqla.models import Meta, Page
|
|
10
10
|
from fastapi_sqla.sqla import _DEFAULT_SESSION_KEY
|
|
11
11
|
|
|
12
12
|
QueryCountDependency = Callable[..., Awaitable[int]]
|
|
@@ -19,7 +19,7 @@ PaginateDependency = Union[DefaultDependency, WithQueryCountDependency]
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
async def default_query_count(session: SqlaAsyncSession, query: Select) -> int:
|
|
22
|
-
result = await session.execute(select(func.count()).select_from(query.subquery()))
|
|
22
|
+
result = await session.execute(select(func.count()).select_from(query.subquery()))
|
|
23
23
|
return cast(int, result.scalar())
|
|
24
24
|
|
|
25
25
|
|
|
@@ -33,20 +33,20 @@ async def paginate_query(
|
|
|
33
33
|
scalars: bool = True,
|
|
34
34
|
) -> Page:
|
|
35
35
|
total_pages = math.ceil(total_items / limit)
|
|
36
|
-
page_number = offset / limit + 1
|
|
37
|
-
query = query.offset(offset).limit(limit)
|
|
36
|
+
page_number = math.floor(offset / limit + 1)
|
|
37
|
+
query = query.offset(offset).limit(limit)
|
|
38
38
|
result = await session.execute(query)
|
|
39
39
|
data = iter(
|
|
40
|
-
cast(Iterator, result.unique().scalars() if scalars else result.mappings())
|
|
40
|
+
cast(Iterator, result.unique().scalars() if scalars else result.mappings())
|
|
41
41
|
)
|
|
42
42
|
return Page(
|
|
43
|
-
data=data,
|
|
44
|
-
meta=
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
data=data, # type: ignore # Expected to be a list
|
|
44
|
+
meta=Meta(
|
|
45
|
+
offset=offset,
|
|
46
|
+
total_items=total_items,
|
|
47
|
+
total_pages=total_pages,
|
|
48
|
+
page_number=page_number,
|
|
49
|
+
),
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
|
|
@@ -20,7 +20,8 @@ def setup(engine: Engine):
|
|
|
20
20
|
aws_rds_iam_enabled = lc_environ.get("fastapi_sqla_aws_rds_iam_enabled") == "true"
|
|
21
21
|
|
|
22
22
|
if aws_rds_iam_enabled:
|
|
23
|
-
|
|
23
|
+
if not boto3_installed:
|
|
24
|
+
raise ImportError(f"boto3 is required for RDS IAM : {boto3_installed_err}")
|
|
24
25
|
# Cache the client at startup
|
|
25
26
|
get_rds_client()
|
|
26
27
|
event.listen(engine, "do_connect", set_connection_token)
|
|
@@ -3,7 +3,7 @@ from typing import Generic, TypeVar
|
|
|
3
3
|
from pydantic import BaseModel, Field
|
|
4
4
|
from pydantic import __version__ as pydantic_version
|
|
5
5
|
|
|
6
|
-
major, _, _ =
|
|
6
|
+
major, _, _ = (int(v) for v in pydantic_version.split("."))
|
|
7
7
|
is_pydantic2 = major == 2
|
|
8
8
|
if is_pydantic2:
|
|
9
9
|
GenericModel = BaseModel
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import math
|
|
2
|
-
from collections.abc import Callable
|
|
2
|
+
from collections.abc import Callable, Iterator
|
|
3
3
|
from functools import singledispatch
|
|
4
|
-
from typing import Annotated,
|
|
4
|
+
from typing import Annotated, Optional, Union, cast
|
|
5
5
|
|
|
6
6
|
from fastapi import Depends, Query
|
|
7
7
|
from sqlalchemy.orm import Query as LegacyQuery
|
|
8
8
|
from sqlalchemy.sql import Select, func, select
|
|
9
9
|
|
|
10
|
-
from fastapi_sqla.models import Page
|
|
10
|
+
from fastapi_sqla.models import Meta, Page
|
|
11
11
|
from fastapi_sqla.sqla import _DEFAULT_SESSION_KEY, SessionDependency, SqlaSession
|
|
12
12
|
|
|
13
13
|
DbQuery = Union[LegacyQuery, Select]
|
|
@@ -52,7 +52,7 @@ def paginate_query(
|
|
|
52
52
|
limit: int,
|
|
53
53
|
scalars: bool = True,
|
|
54
54
|
) -> Page: # pragma: no cover
|
|
55
|
-
"Dispatch on registered functions based on `query` type"
|
|
55
|
+
"""Dispatch on registered functions based on `query` type"""
|
|
56
56
|
raise NotImplementedError(f"no paginate_query registered for type {type(query)!r}")
|
|
57
57
|
|
|
58
58
|
|
|
@@ -66,15 +66,15 @@ def _paginate_legacy(
|
|
|
66
66
|
scalars: bool = True,
|
|
67
67
|
) -> Page:
|
|
68
68
|
total_pages = math.ceil(total_items / limit)
|
|
69
|
-
page_number = offset / limit + 1
|
|
69
|
+
page_number = math.floor(offset / limit + 1)
|
|
70
70
|
return Page(
|
|
71
|
-
data=query.offset(offset).limit(limit).all(),
|
|
72
|
-
meta=
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
data=query.offset(offset).limit(limit).all(),
|
|
72
|
+
meta=Meta(
|
|
73
|
+
offset=offset,
|
|
74
|
+
total_items=total_items,
|
|
75
|
+
total_pages=total_pages,
|
|
76
|
+
page_number=page_number,
|
|
77
|
+
),
|
|
78
78
|
)
|
|
79
79
|
|
|
80
80
|
|
|
@@ -89,20 +89,20 @@ def _paginate(
|
|
|
89
89
|
scalars: bool = True,
|
|
90
90
|
) -> Page:
|
|
91
91
|
total_pages = math.ceil(total_items / limit)
|
|
92
|
-
page_number = offset / limit + 1
|
|
93
|
-
query = query.offset(offset).limit(limit)
|
|
92
|
+
page_number = math.floor(offset / limit + 1)
|
|
93
|
+
query = query.offset(offset).limit(limit)
|
|
94
94
|
result = session.execute(query)
|
|
95
95
|
data = iter(
|
|
96
|
-
cast(Iterator, result.unique().scalars() if scalars else result.mappings())
|
|
96
|
+
cast(Iterator, result.unique().scalars() if scalars else result.mappings())
|
|
97
97
|
)
|
|
98
98
|
return Page(
|
|
99
|
-
data=data,
|
|
100
|
-
meta=
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
data=data, # type: ignore # Expected to be a list
|
|
100
|
+
meta=Meta(
|
|
101
|
+
offset=offset,
|
|
102
|
+
total_items=total_items,
|
|
103
|
+
total_pages=total_pages,
|
|
104
|
+
page_number=page_number,
|
|
105
|
+
),
|
|
106
106
|
)
|
|
107
107
|
|
|
108
108
|
|
|
@@ -2,7 +2,7 @@ import asyncio
|
|
|
2
2
|
import os
|
|
3
3
|
from collections.abc import Generator
|
|
4
4
|
from contextlib import contextmanager
|
|
5
|
-
from typing import Annotated
|
|
5
|
+
from typing import Annotated
|
|
6
6
|
|
|
7
7
|
import structlog
|
|
8
8
|
from fastapi import Depends, Request
|
|
@@ -24,7 +24,7 @@ except ImportError:
|
|
|
24
24
|
DeclarativeBase = declarative_base() # type: ignore
|
|
25
25
|
|
|
26
26
|
try:
|
|
27
|
-
from sqlmodel import Session as SqlaSession # type: ignore
|
|
27
|
+
from sqlmodel import Session as SqlaSession # type: ignore
|
|
28
28
|
|
|
29
29
|
except ImportError:
|
|
30
30
|
pass
|
|
@@ -165,14 +165,11 @@ async def add_session_to_request(
|
|
|
165
165
|
return response
|
|
166
166
|
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
class SessionDependency(Generic[S]):
|
|
168
|
+
class SessionDependency:
|
|
172
169
|
def __init__(self, key: str = _DEFAULT_SESSION_KEY) -> None:
|
|
173
170
|
self.key = key
|
|
174
171
|
|
|
175
|
-
def __call__(self, request: Request) ->
|
|
172
|
+
def __call__(self, request: Request) -> SqlaSession:
|
|
176
173
|
"""Yield the sqlalchemy session for that request.
|
|
177
174
|
|
|
178
175
|
It is meant to be used as a FastAPI dependency::
|
|
@@ -197,5 +194,5 @@ class SessionDependency(Generic[S]):
|
|
|
197
194
|
raise
|
|
198
195
|
|
|
199
196
|
|
|
200
|
-
default_session_dep = SessionDependency
|
|
197
|
+
default_session_dep = SessionDependency()
|
|
201
198
|
Session = Annotated[SqlaSession, Depends(default_session_dep)]
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "fastapi-sqla"
|
|
3
|
+
version = "3.2.1"
|
|
4
|
+
description = "SQLAlchemy extension for FastAPI with support for pagination, asyncio, SQLModel, and pytest, ready for production."
|
|
5
|
+
authors = [
|
|
6
|
+
"Hadrien David <hadrien.david@dialogue.co>",
|
|
7
|
+
"Victor Repkow <victor.repkow@dialogue.co>",
|
|
8
|
+
]
|
|
9
|
+
license = "MIT"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
repository = "https://github.com/dialoguemd/fastapi-sqla"
|
|
12
|
+
keywords = ["FastAPI", "SQLAlchemy", "asyncio", "pytest", "alembic"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 5 - Production/Stable",
|
|
15
|
+
"Environment :: Web Environment",
|
|
16
|
+
"Framework :: AsyncIO",
|
|
17
|
+
"Framework :: FastAPI",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Information Technology",
|
|
20
|
+
"Intended Audience :: System Administrators",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.10",
|
|
27
|
+
"Programming Language :: Python :: 3.9",
|
|
28
|
+
"Programming Language :: Python",
|
|
29
|
+
"Programming Language :: SQL",
|
|
30
|
+
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
|
31
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
32
|
+
"Topic :: Internet",
|
|
33
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
34
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
|
+
"Topic :: Software Development :: Libraries",
|
|
36
|
+
"Topic :: Software Development",
|
|
37
|
+
"Typing :: Typed",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[tool.poetry.dependencies]
|
|
41
|
+
python = "^3.9"
|
|
42
|
+
fastapi = ">=0.95.1"
|
|
43
|
+
pydantic = ">=1"
|
|
44
|
+
sqlalchemy = ">=1.3"
|
|
45
|
+
structlog = ">=20"
|
|
46
|
+
|
|
47
|
+
alembic = { version = "^1.4.3", optional = true}
|
|
48
|
+
asgi_lifespan = { version = "^1.0.1", optional = true}
|
|
49
|
+
asyncpg = {version = "^0.28.0", optional = true}
|
|
50
|
+
Faker = {version = "^14.2.0", optional = true}
|
|
51
|
+
httpx = {version = "^0.23.0", optional = true}
|
|
52
|
+
pdbpp = { version = "^0.10.2", optional = true}
|
|
53
|
+
psycopg2 = { version = "^2.8.6", optional = true}
|
|
54
|
+
pytest = {version = "^7.2.1", optional = true}
|
|
55
|
+
pytest-asyncio = {version = "^0.19.0", optional = true}
|
|
56
|
+
pytest-cov = { version = "^2.10.1", optional = true}
|
|
57
|
+
ruff = {version = "^0.4.5", optional = true}
|
|
58
|
+
tox = {version = "^3.26.0", optional = true}
|
|
59
|
+
boto3 = {version = "^1.24.74", optional = true}
|
|
60
|
+
greenlet = {version = "^3.0.3", optional = true}
|
|
61
|
+
mypy = {version = "^1.0.0", extras = ["tests"], optional = true}
|
|
62
|
+
sqlmodel = { version = "^0.0.14", optional = true }
|
|
63
|
+
|
|
64
|
+
[tool.poetry.extras]
|
|
65
|
+
# Test dependencies as extras so they can be set as extras in tox config
|
|
66
|
+
# More info on https://github.com/python-poetry/poetry/issues/1941
|
|
67
|
+
tests = [
|
|
68
|
+
"alembic",
|
|
69
|
+
"asgi_lifespan",
|
|
70
|
+
"coverage",
|
|
71
|
+
"Faker",
|
|
72
|
+
"greenlet",
|
|
73
|
+
"httpx",
|
|
74
|
+
"mypy",
|
|
75
|
+
"pdbpp",
|
|
76
|
+
"psycopg2",
|
|
77
|
+
"pytest",
|
|
78
|
+
"pytest-asyncio",
|
|
79
|
+
"pytest-cov",
|
|
80
|
+
"pytest-watch",
|
|
81
|
+
"ruff",
|
|
82
|
+
"tox",
|
|
83
|
+
]
|
|
84
|
+
asyncpg = ["asyncpg"]
|
|
85
|
+
aws_rds_iam = ["boto3"]
|
|
86
|
+
sqlmodel = ["sqlmodel"]
|
|
87
|
+
|
|
88
|
+
[build-system]
|
|
89
|
+
requires = ["poetry>=1.3.0"]
|
|
90
|
+
build-backend = "poetry.masonry.api"
|
|
91
|
+
|
|
92
|
+
[tool.semantic_release]
|
|
93
|
+
version_toml = ["pyproject.toml:tool.poetry.version"]
|
|
94
|
+
upload_to_pypi = false
|
|
95
|
+
commit_message = "{version}\n\nVersion generated by python-semantic-release [ci skip]"
|
|
96
|
+
|
|
97
|
+
[tool.poetry.plugins."pytest11"]
|
|
98
|
+
fastapi-sqla = "fastapi_sqla._pytest_plugin"
|
|
99
|
+
|
|
100
|
+
[tool.ruff]
|
|
101
|
+
target-version = "py39"
|
|
102
|
+
|
|
103
|
+
[tool.ruff.lint]
|
|
104
|
+
select = [
|
|
105
|
+
"E", # pycodestyle
|
|
106
|
+
"W", # pycodestyle warnings
|
|
107
|
+
"F", # pyflakes
|
|
108
|
+
"I", # isort
|
|
109
|
+
"N", # pep8-naming
|
|
110
|
+
"D", # pydocstyle
|
|
111
|
+
"UP", # pyupgrade
|
|
112
|
+
"ASYNC", # flake8-async
|
|
113
|
+
"S", # flake8-bandit
|
|
114
|
+
"B", # flake8-bugbear
|
|
115
|
+
"C4", # flake8-comprehensions
|
|
116
|
+
"SIM", # flake8-simplify
|
|
117
|
+
"TD", # flake8-todos
|
|
118
|
+
"ERA", # eradicate
|
|
119
|
+
"PL", # pylint
|
|
120
|
+
"RUF" # ruff
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
# Ignore some pydocstyle rules that Google convention enables
|
|
124
|
+
ignore = [
|
|
125
|
+
"D100",
|
|
126
|
+
"D101",
|
|
127
|
+
"D102",
|
|
128
|
+
"D103",
|
|
129
|
+
"D104",
|
|
130
|
+
"D105",
|
|
131
|
+
"D106",
|
|
132
|
+
"D107",
|
|
133
|
+
"D212",
|
|
134
|
+
"D415",
|
|
135
|
+
"B008", # Enable using functions in default function args. Easier to work with FastAPI dependencies that way
|
|
136
|
+
"C408", # Enable using dict/list/tuple
|
|
137
|
+
"PLR0911", # Disable max number of return
|
|
138
|
+
"PLR0912", # Disable max number of branches
|
|
139
|
+
"PLR0913", # Disable max number of args
|
|
140
|
+
"PLR0915", # Disable max number of statements
|
|
141
|
+
"PLR2004", # Enable magic values
|
|
142
|
+
"SIM105", # Allow using try - except - pass
|
|
143
|
+
"TD001", # Enable FIXMEs
|
|
144
|
+
"TD002", # Enable TODOs without author
|
|
145
|
+
"TD003", # Enable TODOs without issue link
|
|
146
|
+
"N802", # FastAPI dependency conventions is title cased
|
|
147
|
+
"N803", # Same as N802
|
|
148
|
+
"N806", # Same as N802
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
[tool.ruff.lint.extend-per-file-ignores]
|
|
152
|
+
"tests/*" = [
|
|
153
|
+
"S101", # Enable assert
|
|
154
|
+
"S105", # Disable passwords check
|
|
155
|
+
"S106", # Disable passwords check
|
|
156
|
+
"S608", # Allow SQL string construction
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
[tool.ruff.lint.pydocstyle]
|
|
160
|
+
convention = "google"
|
|
161
|
+
|
|
162
|
+
[tool.pytest.ini_options]
|
|
163
|
+
asyncio_mode = "auto"
|
|
164
|
+
testpaths = "tests"
|
|
165
|
+
norecursedirs = ".git,.venv"
|
|
166
|
+
xfail_strict = "true"
|
|
167
|
+
addopts = """
|
|
168
|
+
-p no:fastapi-sqla
|
|
169
|
+
--cov-config pyproject.toml
|
|
170
|
+
--cov-report term
|
|
171
|
+
--cov-report term-missing
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
# https://nedbatchelder.com/blog/201810/why_warnings_is_mysterious.html
|
|
175
|
+
filterwarnings = [
|
|
176
|
+
"error:.*removed in version 2.0.*:",
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
[tool.pytest-watch.run]
|
|
180
|
+
ext = ".py, .yaml, .cfg"
|
|
181
|
+
|
|
182
|
+
[tool.coverage.run]
|
|
183
|
+
branch = true
|
|
184
|
+
omit = [
|
|
185
|
+
"tests/*",
|
|
186
|
+
".venv/*"
|
|
187
|
+
]
|
|
188
|
+
concurrency = ["thread", "greenlet"]
|
|
189
|
+
|
|
190
|
+
[tool.coverage.report]
|
|
191
|
+
skip_covered = true
|
|
192
|
+
|
|
193
|
+
[tool.tox]
|
|
194
|
+
legacy_tox_ini = """
|
|
195
|
+
[tox]
|
|
196
|
+
envlist = sqlalchemy{ 1.3, 1.4, 2.0, 2.0-sqlmodel }-{ asyncpg, noasyncpg }-{aws_rds_iam, noaws_rds_iam }-pydantic{ 1, 2 }
|
|
197
|
+
|
|
198
|
+
[testenv]
|
|
199
|
+
passenv = CI
|
|
200
|
+
deps =
|
|
201
|
+
sqlalchemy1.3: sqlalchemy<1.4
|
|
202
|
+
sqlalchemy1.4: sqlalchemy>=1.4,<2
|
|
203
|
+
sqlalchemy2.0: sqlalchemy>=2
|
|
204
|
+
sqlalchemy2.0-sqlmodel: sqlalchemy>=2
|
|
205
|
+
sqlalchemy2.0-sqlmodel: sqlmodel
|
|
206
|
+
asyncpg: asyncpg
|
|
207
|
+
aws_rds_iam: boto3
|
|
208
|
+
pydantic1: pydantic<2
|
|
209
|
+
pydantic2: pydantic>=2
|
|
210
|
+
|
|
211
|
+
extras =
|
|
212
|
+
tests
|
|
213
|
+
|
|
214
|
+
commands = pytest -vv --cov={envsitepackagesdir}/fastapi_sqla --cov-report xml --cov-report html --junitxml=test-reports/pytest/junit.xml
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
[tool.mypy]
|
|
218
|
+
exclude = ["tests"]
|
|
219
|
+
ignore_missing_imports = true
|
|
220
|
+
plugins = "sqlalchemy.ext.mypy.plugin"
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
[tool]
|
|
2
|
-
[tool.poetry]
|
|
3
|
-
name = "fastapi-sqla"
|
|
4
|
-
version = "3.1.1"
|
|
5
|
-
description = "SQLAlchemy extension for FastAPI with support for pagination, asyncio, and pytest, ready for production."
|
|
6
|
-
authors = ["Hadrien David <hadrien.david@dialogue.co>", "Victor Repkow <victor.repkow@dialogue.co>"]
|
|
7
|
-
license = "MIT"
|
|
8
|
-
readme = "README.md"
|
|
9
|
-
repository = "https://github.com/dialoguemd/fastapi-sqla"
|
|
10
|
-
keywords = ["FastAPI", "SQLAlchemy", "asyncio", "pytest", "alembic"]
|
|
11
|
-
classifiers = ["Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: AsyncIO", "Framework :: FastAPI", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.9", "Programming Language :: Python", "Programming Language :: SQL", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries", "Topic :: Software Development", "Typing :: Typed"]
|
|
12
|
-
[tool.poetry.dependencies]
|
|
13
|
-
python = "^3.9"
|
|
14
|
-
fastapi = ">=0.95.1"
|
|
15
|
-
pydantic = ">=1"
|
|
16
|
-
sqlalchemy = ">=1.3"
|
|
17
|
-
structlog = ">=20"
|
|
18
|
-
[tool.poetry.dependencies.alembic]
|
|
19
|
-
version = "^1.4.3"
|
|
20
|
-
optional = true
|
|
21
|
-
[tool.poetry.dependencies.asgi_lifespan]
|
|
22
|
-
version = "^1.0.1"
|
|
23
|
-
optional = true
|
|
24
|
-
[tool.poetry.dependencies.asyncpg]
|
|
25
|
-
version = "^0.28.0"
|
|
26
|
-
optional = true
|
|
27
|
-
[tool.poetry.dependencies.black]
|
|
28
|
-
version = "^22.8.0"
|
|
29
|
-
optional = true
|
|
30
|
-
[tool.poetry.dependencies.Faker]
|
|
31
|
-
version = "^14.2.0"
|
|
32
|
-
optional = true
|
|
33
|
-
[tool.poetry.dependencies.httpx]
|
|
34
|
-
version = "^0.23.0"
|
|
35
|
-
optional = true
|
|
36
|
-
[tool.poetry.dependencies.isort]
|
|
37
|
-
version = "^5.5.3"
|
|
38
|
-
optional = true
|
|
39
|
-
[tool.poetry.dependencies.pdbpp]
|
|
40
|
-
version = "^0.10.2"
|
|
41
|
-
optional = true
|
|
42
|
-
[tool.poetry.dependencies.psycopg2]
|
|
43
|
-
version = "^2.8.6"
|
|
44
|
-
optional = true
|
|
45
|
-
[tool.poetry.dependencies.pylama]
|
|
46
|
-
version = "^8.4.1"
|
|
47
|
-
optional = true
|
|
48
|
-
[tool.poetry.dependencies.pytest]
|
|
49
|
-
version = "^7.2.1"
|
|
50
|
-
optional = true
|
|
51
|
-
[tool.poetry.dependencies.pytest-asyncio]
|
|
52
|
-
version = "^0.19.0"
|
|
53
|
-
optional = true
|
|
54
|
-
[tool.poetry.dependencies.pytest-cov]
|
|
55
|
-
version = "^2.10.1"
|
|
56
|
-
optional = true
|
|
57
|
-
[tool.poetry.dependencies.tox]
|
|
58
|
-
version = "^3.26.0"
|
|
59
|
-
optional = true
|
|
60
|
-
[tool.poetry.dependencies.boto3]
|
|
61
|
-
version = "^1.24.74"
|
|
62
|
-
optional = true
|
|
63
|
-
[tool.poetry.dependencies.greenlet]
|
|
64
|
-
version = "^1.1.3"
|
|
65
|
-
optional = true
|
|
66
|
-
[tool.poetry.dependencies.mypy]
|
|
67
|
-
version = "^0.991"
|
|
68
|
-
extras = ["tests"]
|
|
69
|
-
optional = true
|
|
70
|
-
[tool.poetry.dependencies.sqlmodel]
|
|
71
|
-
version = "^0.0.14"
|
|
72
|
-
optional = true
|
|
73
|
-
[tool.poetry.extras]
|
|
74
|
-
tests = ["alembic", "asgi_lifespan", "black", "coverage", "Faker", "greenlet", "httpx", "isort", "mypy", "pdbpp", "psycopg2", "pylama", "pytest", "pytest-asyncio", "pytest-cov", "pytest-watch", "tox"]
|
|
75
|
-
asyncpg = ["asyncpg"]
|
|
76
|
-
aws_rds_iam = ["boto3"]
|
|
77
|
-
sqlmodel = ["sqlmodel"]
|
|
78
|
-
[tool.poetry.plugins]
|
|
79
|
-
[tool.poetry.plugins.pytest11]
|
|
80
|
-
fastapi-sqla = "fastapi_sqla._pytest_plugin"
|
|
81
|
-
|
|
82
|
-
[[tool.poetry.source]]
|
|
83
|
-
name = "dialogue-private"
|
|
84
|
-
url = "https://dialogue-527641002329.d.codeartifact.us-east-1.amazonaws.com/pypi/distribution-readonly/simple/"
|
|
85
|
-
default = true
|
|
86
|
-
[tool.semantic_release]
|
|
87
|
-
version_variable = "pyproject.toml:version"
|
|
88
|
-
upload_to_pypi = false
|
|
89
|
-
commit_message = "Version generated by python-semantic-release [ci skip]"
|
|
90
|
-
[tool.pylama]
|
|
91
|
-
paths = "fastapi_sqla tests"
|
|
92
|
-
linters = "pycodestyle,mccabe,pyflakes"
|
|
93
|
-
[tool.pylama.linter]
|
|
94
|
-
[tool.pylama.linter.pycodestyle]
|
|
95
|
-
max_line_length = 88
|
|
96
|
-
[tool.isort]
|
|
97
|
-
profile = "black"
|
|
98
|
-
lines_between_sections = 1
|
|
99
|
-
multi_line_output = 3
|
|
100
|
-
include_trailing_comma = "True"
|
|
101
|
-
line_length = 88
|
|
102
|
-
[tool.pytest]
|
|
103
|
-
[tool.pytest.ini_options]
|
|
104
|
-
asyncio_mode = "auto"
|
|
105
|
-
testpaths = "tests"
|
|
106
|
-
norecursedirs = ".git,.venv"
|
|
107
|
-
xfail_strict = "true"
|
|
108
|
-
addopts = " -p no:fastapi-sqla\n --cov-config pyproject.toml\n --cov-report term\n --cov-report term-missing\n"
|
|
109
|
-
filterwarnings = ["error:.*removed in version 2.0.*:"]
|
|
110
|
-
[tool.pytest-watch]
|
|
111
|
-
[tool.pytest-watch.run]
|
|
112
|
-
ext = ".py, .yaml, .cfg"
|
|
113
|
-
[tool.coverage]
|
|
114
|
-
[tool.coverage.run]
|
|
115
|
-
branch = true
|
|
116
|
-
omit = ["tests/*", ".venv/*"]
|
|
117
|
-
concurrency = ["thread", "greenlet"]
|
|
118
|
-
[tool.coverage.report]
|
|
119
|
-
skip_covered = true
|
|
120
|
-
[tool.tox]
|
|
121
|
-
legacy_tox_ini = "[tox]\nenvlist = sqlalchemy{ 1.3, 1.4, 2.0, 2.0-sqlmodel }-{ asyncpg, noasyncpg }-{aws_rds_iam, noaws_rds_iam }-pydantic{ 1, 2 }\n\n[testenv]\npassenv = CI\ndeps =\n sqlalchemy1.3: sqlalchemy<1.4\n sqlalchemy1.4: sqlalchemy>=1.4,<2\n sqlalchemy2.0: sqlalchemy>=2\n sqlalchemy2.0-sqlmodel: sqlalchemy>=2\n sqlalchemy2.0-sqlmodel: sqlmodel\n asyncpg: asyncpg\n aws_rds_iam: boto3\n pydantic1: pydantic<2\n pydantic2: pydantic>=2\n\nextras =\n tests\n\ncommands = pytest -vv --cov={envsitepackagesdir}/fastapi_sqla --cov-report xml --cov-report html --junitxml=test-reports/pytest/junit.xml\n"
|
|
122
|
-
[tool.black]
|
|
123
|
-
exclude = ".mypy_cache|.pytest_cache|.vscode|.eggs|venv"
|
|
124
|
-
--skip-magic-trailing-comma = true
|
|
125
|
-
[tool.mypy]
|
|
126
|
-
exclude = ["tests"]
|
|
127
|
-
ignore_missing_imports = true
|
|
128
|
-
plugins = "sqlalchemy.ext.mypy.plugin"
|
|
129
|
-
|
|
130
|
-
[build-system]
|
|
131
|
-
requires = ["poetry>=1.3.0"]
|
|
132
|
-
build-backend = "poetry.masonry.api"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|