Skip to content

Commit 9a68b92

Browse files
fix compatability
1 parent bdabd4b commit 9a68b92

File tree

11 files changed

+1248
-83
lines changed

11 files changed

+1248
-83
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ pytest-plugin-work
2121
old
2222
examples/two/
2323
*.sqlite
24-
*.db
24+
*.db
25+
.pdm-python

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.13
1+
3.8.16

pdm.lock

Lines changed: 1131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,56 @@
11
[project]
22
name = "quart-sqlalchemy"
3-
version = "3.0.2"
3+
version = "3.0.3"
44
description = "SQLAlchemy for humans, with framework adapter for Quart."
55
authors = [
66
{name = "Joe Black", email = "[email protected]"},
77
]
88
dependencies = [
9-
"quart>=0.18.3",
10-
"SQLAlchemy[asyncio]>=1.4.35, <2.1.0",
9+
"quart<0.20.0,>=0.18.3",
10+
"werkzeug<3.1.0,>=2.2.0",
11+
"blinker<1.7,>=1.5",
12+
"SQLAlchemy[asyncio]<2.1.0,>=2.0.0",
1113
"SQLAlchemy-Utils",
12-
"anyio",
13-
"aiosqlite",
14-
"pydantic",
15-
"tenacity",
14+
"anyio~=3.3.4",
15+
"pydantic~=1.10.13",
16+
"tenacity~=8.0.1",
1617
"sqlapagination",
17-
"exceptiongroup"
18+
"exceptiongroup",
1819
]
19-
requires-python = ">=3.7"
20+
requires-python = ">=3.8"
2021
readme = "README.rst"
2122
license = {text = "MIT"}
2223

2324
[project.urls]
2425
"Homepage" = "https://github.com/joeblackwaslike/quart-sqlalchemy"
2526
"Bug Tracker" = "https://github.com/joeblackwaslike/quart-sqlalchemy/issues"
2627

28+
2729
[build-system]
28-
requires = ["setuptools", "setuptools-scm"]
29-
build-backend = "setuptools.build_meta"
30+
requires = ["pdm-backend"]
31+
build-backend = "pdm.backend"
3032

3133

32-
[project.optional-dependencies]
33-
tests = [
34-
"pytest",
35-
# "pytest-asyncio~=0.20.3",
36-
# "pytest-asyncio @ https://github.com/joeblackwaslike/pytest-asyncio/releases/download/v0.20.4.dev42/pytest_asyncio-0.20.4.dev42-py3-none-any.whl",
37-
"pytest-asyncio @ https://github.com/joeblackwaslike/pytest-asyncio/releases/download/v0.20.4.dev43/pytest_asyncio-0.20.4.dev43-py3-none-any.whl",
38-
"pytest-mock",
39-
"pytest-cov",
40-
"coverage[toml]",
41-
]
34+
[tool.pdm.dev-dependencies]
4235
dev = [
43-
"pre-commit",
44-
"tox",
45-
"tox-pdm",
46-
"mypy",
47-
"wemake-python-styleguide",
48-
"IPython",
49-
"black",
50-
]
51-
docs = [
52-
"sphinx",
53-
"pallets-sphinx-themes",
54-
"sphinx-issues",
55-
"sphinxcontrib-log-cabinet",
36+
"pytest>=7.4.3",
37+
# "pytest-asyncio~=0.20.3",
38+
"pytest-asyncio @ https://github.com/joeblackwaslike/pytest-asyncio/releases/download/v0.20.4.dev42/pytest_asyncio-0.20.4.dev42-py3-none-any.whl",
39+
"pytest-mock>=3.12.0",
40+
"pytest-cov>=4.1.0",
41+
"coverage[toml]>=7.3.2",
42+
"aiosqlite>=0.19.0",
43+
"pre-commit>=3.5.0",
44+
"tox>=4.11.3",
45+
"tox-pdm>=0.7.0",
46+
"mypy>=1.7.0",
47+
"ruff>=0.1.5",
5648
]
5749

50+
5851
[tool.pdm.build]
5952
source-includes = [
6053
"docs/",
61-
# "examples/",
6254
"tests/",
6355
"CHANGES.rst",
6456
"pdm.lock",

src/quart_sqlalchemy/__init__.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.0.2"
1+
__version__ = "3.0.3"
22

33
from .bind import AsyncBind
44
from .bind import Bind
@@ -21,3 +21,28 @@
2121
from .session import AsyncSession
2222
from .session import Session
2323
from .sqla import SQLAlchemy
24+
25+
26+
__all__ = [
27+
"AsyncBind",
28+
"AsyncBindConfig",
29+
"AsyncSession",
30+
"AsyncSessionmakerOptions",
31+
"AsyncSessionOptions",
32+
"Base",
33+
"Bind",
34+
"BindConfig",
35+
"BindContext",
36+
"ConfigBase",
37+
"CoreExecutionOptions",
38+
"EngineConfig",
39+
"ORMExecutionOptions",
40+
"Session",
41+
"SessionOptions",
42+
"SessionmakerOptions",
43+
"SQLAlchemy",
44+
"SQLAlchemyConfig",
45+
"retry_config",
46+
"retrying_async_session",
47+
"retrying_session",
48+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
from .extension import QuartSQLAlchemy
2+
3+
4+
__all__ = ["QuartSQLAlchemy"]

src/quart_sqlalchemy/model/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,24 @@
1515
from .mixins import TimestampMixin
1616
from .mixins import VersionMixin
1717
from .model import Base
18+
19+
20+
__all__ = [
21+
"Base",
22+
"CreatedTimestamp",
23+
"DynamicArgsMixin",
24+
"IdentityMixin",
25+
"Json",
26+
"PrimaryKey",
27+
"PydanticType",
28+
"RecursiveDictMixin",
29+
"ReprMixin",
30+
"setup_soft_delete_for_session",
31+
"SimpleDictMixin",
32+
"SoftDeleteMixin",
33+
"TableNameMixin",
34+
"TimestampMixin",
35+
"TZDateTime",
36+
"UpdatedTimestamp",
37+
"VersionMixin",
38+
]

src/quart_sqlalchemy/model/mixins.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ def model_to_dict(
106106

107107
mapper = sa.inspect(obj).mapper
108108
columns = [column.key for column in mapper.columns]
109-
get_key_value = (
110-
lambda c: (c, getattr(obj, c).isoformat())
111-
if isinstance(getattr(obj, c), datetime)
112-
else (c, getattr(obj, c))
113-
)
109+
110+
def get_key_value(c):
111+
return (
112+
(c, getattr(obj, c).isoformat())
113+
if isinstance(getattr(obj, c), datetime)
114+
else (c, getattr(obj, c))
115+
)
116+
114117
data = dict(map(get_key_value, columns))
115118

116119
if max_depth > 0:
@@ -125,7 +128,9 @@ def model_to_dict(
125128
if relationship_children is not None:
126129
if relation.uselist:
127130
children = []
128-
for child in (c for c in relationship_children if c not in _children_seen):
131+
for child in (
132+
c for c in relationship_children if c not in _children_seen
133+
):
129134
_children_seen.add(child)
130135
children.append(
131136
self.model_to_dict(
@@ -148,7 +153,9 @@ def model_to_dict(
148153

149154

150155
class IdentityMixin:
151-
id: Mapped[int] = sa.orm.mapped_column(sa.Identity(), primary_key=True, autoincrement=True)
156+
id: Mapped[int] = sa.orm.mapped_column(
157+
sa.Identity(), primary_key=True, autoincrement=True
158+
)
152159

153160

154161
class SoftDeleteMixin:

src/quart_sqlalchemy/signals.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
import sqlalchemy
44
import sqlalchemy.orm
55
from blinker import Namespace
6-
from quart.signals import AsyncNamespace
76

87

98
sa = sqlalchemy
109

11-
sync_signals = Namespace()
12-
async_signals = AsyncNamespace()
10+
_signals = Namespace()
1311

1412

15-
before_bind_engine_created = sync_signals.signal(
13+
before_bind_engine_created = _signals.signal(
1614
"quart-sqlalchemy.bind.engine.created.before",
1715
doc="""Called before a bind creates an engine.
1816
@@ -25,7 +23,7 @@ def handler(
2523
...
2624
""",
2725
)
28-
after_bind_engine_created = sync_signals.signal(
26+
after_bind_engine_created = _signals.signal(
2927
"quart-sqlalchemy.bind.engine.created.after",
3028
doc="""Called after a bind creates an engine.
3129
@@ -40,7 +38,7 @@ def handler(
4038
""",
4139
)
4240

43-
before_bind_session_factory_created = sync_signals.signal(
41+
before_bind_session_factory_created = _signals.signal(
4442
"quart-sqlalchemy.bind.session_factory.created.before",
4543
doc="""Called before a bind creates a session_factory.
4644
@@ -49,7 +47,7 @@ def handler(sender: t.Union[Bind, AsyncBind], options: Dict[str, Any]) -> None:
4947
...
5048
""",
5149
)
52-
after_bind_session_factory_created = sync_signals.signal(
50+
after_bind_session_factory_created = _signals.signal(
5351
"quart-sqlalchemy.bind.session_factory.created.after",
5452
doc="""Called after a bind creates a session_factory.
5553
@@ -64,7 +62,7 @@ def handler(
6462
)
6563

6664

67-
bind_context_entered = sync_signals.signal(
65+
bind_context_entered = _signals.signal(
6866
"quart-sqlalchemy.bind.context.entered",
6967
doc="""Called when a bind context is entered.
7068
@@ -79,7 +77,7 @@ def handler(
7977
""",
8078
)
8179

82-
bind_context_exited = sync_signals.signal(
80+
bind_context_exited = _signals.signal(
8381
"quart-sqlalchemy.bind.context.exited",
8482
doc="""Called when a bind context is exited.
8583
@@ -95,7 +93,7 @@ def handler(
9593
)
9694

9795

98-
before_framework_extension_initialization = sync_signals.signal(
96+
before_framework_extension_initialization = _signals.signal(
9997
"quart-sqlalchemy.framework.extension.initialization.before",
10098
doc="""Fired before SQLAlchemy.init_app(app) is called.
10199
@@ -104,7 +102,7 @@ def handle(sender: QuartSQLAlchemy, app: Quart):
104102
...
105103
""",
106104
)
107-
after_framework_extension_initialization = sync_signals.signal(
105+
after_framework_extension_initialization = _signals.signal(
108106
"quart-sqlalchemy.framework.extension.initialization.after",
109107
doc="""Fired after SQLAlchemy.init_app(app) is called.
110108
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
from .transaction import AsyncTestTransaction
22
from .transaction import TestTransaction
3+
4+
5+
__all__ = ["AsyncTestTransaction", "TestTransaction"]

0 commit comments

Comments
 (0)