lush-sqlalchemyx 0.2.0__tar.gz → 0.3.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.
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/PKG-INFO +2 -2
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/pyproject.toml +29 -2
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/_compat.py +2 -5
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/base/dal/__init__.py +94 -47
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/base/dal/_async.py +166 -33
- lush_sqlalchemyx-0.3.0/src/lush_sqlalchemyx/base/dal/_async_v2.py +184 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/base/dal/_common.py +40 -26
- lush_sqlalchemyx-0.3.0/src/lush_sqlalchemyx/base/dal/_pagination.py +90 -0
- lush_sqlalchemyx-0.3.0/src/lush_sqlalchemyx/base/dal/_params.py +32 -0
- lush_sqlalchemyx-0.3.0/src/lush_sqlalchemyx/base/dal/_repository.py +311 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/base/dal/_sync.py +167 -68
- lush_sqlalchemyx-0.3.0/src/lush_sqlalchemyx/base/dal/_sync_v2.py +183 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/integrations/flask/ext.py +8 -14
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/README.md +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/base/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/integrations/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/integrations/fastapi/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/integrations/fastapi/depends/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/integrations/flask/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/mgrs/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/mgrs/mysql/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/mgrs/mysql/manager.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/mgrs/mysql/mapper.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/mgrs/mysql/sync_manager.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/mgrs/mysql/sync_mapper.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/py.typed +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/same_impl_just_warn_wrapper.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/shortcuts/__init__.py +0 -0
- {lush_sqlalchemyx-0.2.0 → lush_sqlalchemyx-0.3.0}/src/lush_sqlalchemyx/shortcuts/meta.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: lush-sqlalchemyx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: SQLAlchemy helpers (DAL) and async MySQL managers, with some web frameworks integrations
|
|
5
5
|
Author: straydragon
|
|
6
6
|
Author-email: straydragon <straydragonl@foxmail.com>
|
|
@@ -8,7 +8,7 @@ License: Apache-2.0
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.10
|
|
10
10
|
Requires-Dist: sqlalchemy>=2.0.21
|
|
11
|
-
Requires-Dist: pydantic>=2.
|
|
11
|
+
Requires-Dist: pydantic>=2.3.0,<3.0.0
|
|
12
12
|
Requires-Dist: typing-extensions>=4.12.2
|
|
13
13
|
Requires-Dist: lush-pydanticx>=0.1.0
|
|
14
14
|
Requires-Dist: lush-stdx>=0.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "lush-sqlalchemyx"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "SQLAlchemy helpers (DAL) and async MySQL managers, with some web frameworks integrations"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -12,7 +12,7 @@ classifiers = [
|
|
|
12
12
|
]
|
|
13
13
|
dependencies = [
|
|
14
14
|
"sqlalchemy>=2.0.21",
|
|
15
|
-
"pydantic>=2.
|
|
15
|
+
"pydantic>=2.3.0,<3.0.0",
|
|
16
16
|
"typing-extensions>=4.12.2",
|
|
17
17
|
"lush-pydanticx>=0.1.0",
|
|
18
18
|
"lush-stdx>=0.1.0",
|
|
@@ -47,6 +47,8 @@ dev = [
|
|
|
47
47
|
"sqlalchemy[asyncio]>=2.0.43",
|
|
48
48
|
"flask-sqlalchemy>=3.1.1",
|
|
49
49
|
"flask>=3.0.0",
|
|
50
|
+
"pytest-benchmark>=5.2.3",
|
|
51
|
+
"pymysql>=1.1.2",
|
|
50
52
|
]
|
|
51
53
|
|
|
52
54
|
[tool.pytest.ini_options]
|
|
@@ -138,9 +140,18 @@ ignore = [
|
|
|
138
140
|
# === 其他 ===
|
|
139
141
|
"D", # 文档字符串相关规则
|
|
140
142
|
"EM", # 错误消息相关规则
|
|
143
|
+
|
|
144
|
+
# === 新增 (ruff v0.15+) ===
|
|
145
|
+
"PLC0105", # TypeVar 命名约定 (重命名会破坏 API)
|
|
146
|
+
"PLW0127", # 自赋值重导出 (intentional re-export)
|
|
147
|
+
"RUF022", # __all__ 排序 (intentional grouping)
|
|
148
|
+
"RUF002", # 中文 docstring 中使用全角标点
|
|
141
149
|
]
|
|
142
150
|
|
|
143
151
|
[tool.ruff.lint.per-file-ignores]
|
|
152
|
+
"**/dal/_*_v2.py" = [
|
|
153
|
+
"ARG003", # extra 参数是 ABC 合规所必需但在部分方法中未使用
|
|
154
|
+
]
|
|
144
155
|
"tests/**/*.py" = [
|
|
145
156
|
# === 测试代码质量 ===
|
|
146
157
|
"B011", # assert False应改为raise AssertionError
|
|
@@ -155,6 +166,7 @@ ignore = [
|
|
|
155
166
|
"N802", # 函数名不规范
|
|
156
167
|
"PERF401", # 性能相关
|
|
157
168
|
"PT", # assert 相关
|
|
169
|
+
"E402", # 模块级导入不在顶部
|
|
158
170
|
|
|
159
171
|
# === 测试安全相关 ===
|
|
160
172
|
"S101", # assert语句(测试中使用)
|
|
@@ -242,6 +254,7 @@ reportAny = "none"
|
|
|
242
254
|
reportExplicitAny = "none"
|
|
243
255
|
reportConstantRedefinition = "none"
|
|
244
256
|
reportUnnecessaryComparison = "none"
|
|
257
|
+
reportImplicitOverride = false
|
|
245
258
|
|
|
246
259
|
[[tool.basedpyright.executionEnvironments]]
|
|
247
260
|
root = "tests"
|
|
@@ -270,10 +283,24 @@ reportMissingTypeArgument = false
|
|
|
270
283
|
reportOptionalMemberAccess = false
|
|
271
284
|
reportAttributeAccessIssue = "none"
|
|
272
285
|
reportGeneralTypeIssues = false
|
|
286
|
+
reportAssignmentType = false
|
|
273
287
|
reportOperatorIssue = false
|
|
274
288
|
reportIndexIssue = false
|
|
275
289
|
reportInvalidTypeArguments = "none"
|
|
290
|
+
reportUnknownLambdaType = false
|
|
291
|
+
reportImplicitOverride = false
|
|
292
|
+
reportUnusedClass = false
|
|
293
|
+
|
|
276
294
|
|
|
295
|
+
[[tool.basedpyright.executionEnvironments]]
|
|
296
|
+
root = "src/lush_sqlalchemyx/integrations"
|
|
297
|
+
reportAttributeAccessIssue = "none"
|
|
298
|
+
reportAssignmentType = false
|
|
299
|
+
reportImportCycles = false
|
|
300
|
+
reportUnknownVariableType = false
|
|
301
|
+
reportUnknownParameterType = false
|
|
302
|
+
reportUnknownMemberType = false
|
|
303
|
+
reportUnknownArgumentType = false
|
|
277
304
|
|
|
278
305
|
[[tool.basedpyright.executionEnvironments]]
|
|
279
306
|
root = "src"
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
_HAS_ASYNC: bool
|
|
6
6
|
try:
|
|
7
|
-
from sqlalchemy.ext.asyncio import AsyncSession as _AsyncSession # noqa: F401
|
|
7
|
+
from sqlalchemy.ext.asyncio import AsyncSession as _AsyncSession # noqa: F401 # pyright: ignore[reportUnusedImport]
|
|
8
8
|
|
|
9
9
|
_HAS_ASYNC = True
|
|
10
10
|
except ImportError: # pragma: no cover
|
|
@@ -18,7 +18,4 @@ def require_async() -> None:
|
|
|
18
18
|
以便用户看到清晰的错误信息而非深层调用栈中的 ``AttributeError``.
|
|
19
19
|
"""
|
|
20
20
|
if not _HAS_ASYNC:
|
|
21
|
-
raise ImportError(
|
|
22
|
-
"Async support requires 'sqlalchemy[asyncio]' (greenlet). "
|
|
23
|
-
"Install with: pip install 'lush-sqlalchemyx[asyncio]'"
|
|
24
|
-
)
|
|
21
|
+
raise ImportError("Async support requires 'sqlalchemy[asyncio]' (greenlet). Install with: pip install 'lush-sqlalchemyx[asyncio]'")
|
|
@@ -4,6 +4,45 @@
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
# --- shared (sync/async agnostic) ---
|
|
7
|
+
# --- lush-dal-protocol ABCs (ORM 无关的抽象层) ---
|
|
8
|
+
from lush_dal_protocol import (
|
|
9
|
+
AbstractAsyncAdvancedWriteDAL,
|
|
10
|
+
AbstractAsyncBaseDAL,
|
|
11
|
+
AbstractAsyncBatchFieldDAL,
|
|
12
|
+
AbstractAsyncLockDAL,
|
|
13
|
+
AbstractAsyncRawSQLDAL,
|
|
14
|
+
AbstractAsyncReadDAL,
|
|
15
|
+
AbstractAsyncWriteDAL,
|
|
16
|
+
AbstractSyncAdvancedWriteDAL,
|
|
17
|
+
AbstractSyncBaseDAL,
|
|
18
|
+
AbstractSyncBatchFieldDAL,
|
|
19
|
+
AbstractSyncLockDAL,
|
|
20
|
+
AbstractSyncRawSQLDAL,
|
|
21
|
+
AbstractSyncReadDAL,
|
|
22
|
+
AbstractSyncWriteDAL,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# --- async (requires sqlalchemy[asyncio]) ---
|
|
26
|
+
from ._async import (
|
|
27
|
+
AsyncBaseDAL,
|
|
28
|
+
AsyncRawDAL,
|
|
29
|
+
AsyncRawReadDAL,
|
|
30
|
+
AsyncReadDAL,
|
|
31
|
+
AsyncSqlATableBase,
|
|
32
|
+
AsyncSQLATableT,
|
|
33
|
+
AsyncWriteDAL,
|
|
34
|
+
AsyncXDALOp,
|
|
35
|
+
BasicAsyncBaseTable,
|
|
36
|
+
ReadOnlyAsyncBaseDAL,
|
|
37
|
+
ReadOnlyBasicAsyncBaseTable,
|
|
38
|
+
StdAsyncBaseTable,
|
|
39
|
+
StdReadOnlyBasicAsyncBaseTable,
|
|
40
|
+
async_temp_set_lock_wait_timeout,
|
|
41
|
+
async_with_retry,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# --- V2 (ABC-compliant, options-based) ---
|
|
45
|
+
from ._async_v2 import AsyncBaseDALV2, AsyncReadDALV2, AsyncWriteDALV2
|
|
7
46
|
from ._common import (
|
|
8
47
|
DEFAULT_RETRY_CONFIG,
|
|
9
48
|
OPTIMISTIC_LOCK_ERROR_MSG_TRAIT,
|
|
@@ -11,56 +50,37 @@ from ._common import (
|
|
|
11
50
|
READONLY_SESSION_FLAG,
|
|
12
51
|
BaseCU,
|
|
13
52
|
BaseDTO,
|
|
14
|
-
BaseModelT,
|
|
15
53
|
CUModelT,
|
|
16
54
|
DBRetryableError,
|
|
17
55
|
DTOModelT,
|
|
18
56
|
FieldMixin,
|
|
19
57
|
ReadOnlyMixin,
|
|
20
58
|
RetryConfig,
|
|
21
|
-
SQLATableT,
|
|
22
59
|
SoftDeleteTableMixin,
|
|
60
|
+
SQLATableT,
|
|
23
61
|
StdBaseCU,
|
|
24
62
|
StdBaseDTO,
|
|
25
|
-
T,
|
|
26
|
-
V,
|
|
27
|
-
_ensure_strict_fields,
|
|
28
63
|
escape_like,
|
|
29
64
|
filtered_in_sql_values,
|
|
30
65
|
)
|
|
31
66
|
|
|
32
67
|
# Event listener references — accessed by tests via getattr(module, name).
|
|
33
|
-
from ._common import __prevent_readonly_write as __prevent_readonly_write #
|
|
34
|
-
from ._common import __receive_before_flush as __receive_before_flush #
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
BasicAsyncBaseTable,
|
|
47
|
-
ReadOnlyAsyncBaseDAL,
|
|
48
|
-
ReadOnlyBasicAsyncBaseTable,
|
|
49
|
-
StdAsyncBaseTable,
|
|
50
|
-
StdReadOnlyBasicAsyncBaseTable,
|
|
51
|
-
async_temp_set_lock_wait_timeout,
|
|
52
|
-
async_with_retry,
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
# --- lush-dal-protocol protocols (ORM 无关的抽象层) ---
|
|
56
|
-
from lush_dal_protocol import (
|
|
57
|
-
AsyncBaseDALProtocol,
|
|
58
|
-
AsyncReadDALProtocol,
|
|
59
|
-
AsyncWriteDALProtocol,
|
|
60
|
-
SyncBaseDALProtocol,
|
|
61
|
-
SyncReadDALProtocol,
|
|
62
|
-
SyncWriteDALProtocol,
|
|
68
|
+
from ._common import __prevent_readonly_write as __prevent_readonly_write # pyright: ignore[reportPrivateUsage]
|
|
69
|
+
from ._common import __receive_before_flush as __receive_before_flush # pyright: ignore[reportPrivateUsage]
|
|
70
|
+
from ._pagination import (
|
|
71
|
+
CursorPagination,
|
|
72
|
+
CursorResult,
|
|
73
|
+
OffsetPagination,
|
|
74
|
+
PageResult,
|
|
75
|
+
build_cursor_stmt,
|
|
76
|
+
build_offset_stmt,
|
|
77
|
+
decode_cursor,
|
|
78
|
+
encode_cursor,
|
|
79
|
+
make_cursor_result,
|
|
80
|
+
make_page_result,
|
|
63
81
|
)
|
|
82
|
+
from ._params import SQLAExtra
|
|
83
|
+
from ._repository import AsyncSQLAlchemyRepository, SyncSQLAlchemyRepository
|
|
64
84
|
|
|
65
85
|
# --- sync ---
|
|
66
86
|
from ._sync import (
|
|
@@ -73,13 +93,14 @@ from ._sync import (
|
|
|
73
93
|
SyncRawDAL,
|
|
74
94
|
SyncRawReadDAL,
|
|
75
95
|
SyncReadDAL,
|
|
76
|
-
SyncSQLATableT,
|
|
77
96
|
SyncSqlATableBase,
|
|
97
|
+
SyncSQLATableT,
|
|
78
98
|
SyncWriteDAL,
|
|
79
99
|
SyncXDALOp,
|
|
80
100
|
sync_temp_set_lock_wait_timeout,
|
|
81
101
|
sync_with_retry,
|
|
82
102
|
)
|
|
103
|
+
from ._sync_v2 import SyncBaseDALV2, SyncReadDALV2, SyncWriteDALV2
|
|
83
104
|
|
|
84
105
|
__all__ = (
|
|
85
106
|
# common
|
|
@@ -89,7 +110,6 @@ __all__ = (
|
|
|
89
110
|
"READONLY_SESSION_FLAG",
|
|
90
111
|
"BaseCU",
|
|
91
112
|
"BaseDTO",
|
|
92
|
-
"BaseModelT",
|
|
93
113
|
"CUModelT",
|
|
94
114
|
"DBRetryableError",
|
|
95
115
|
"DTOModelT",
|
|
@@ -100,9 +120,6 @@ __all__ = (
|
|
|
100
120
|
"SoftDeleteTableMixin",
|
|
101
121
|
"StdBaseCU",
|
|
102
122
|
"StdBaseDTO",
|
|
103
|
-
"T",
|
|
104
|
-
"V",
|
|
105
|
-
"_ensure_strict_fields",
|
|
106
123
|
"escape_like",
|
|
107
124
|
"filtered_in_sql_values",
|
|
108
125
|
# async
|
|
@@ -137,11 +154,41 @@ __all__ = (
|
|
|
137
154
|
"SyncXDALOp",
|
|
138
155
|
"sync_temp_set_lock_wait_timeout",
|
|
139
156
|
"sync_with_retry",
|
|
140
|
-
#
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
157
|
+
# pagination
|
|
158
|
+
"CursorPagination",
|
|
159
|
+
"CursorResult",
|
|
160
|
+
"OffsetPagination",
|
|
161
|
+
"PageResult",
|
|
162
|
+
"build_cursor_stmt",
|
|
163
|
+
"build_offset_stmt",
|
|
164
|
+
"decode_cursor",
|
|
165
|
+
"encode_cursor",
|
|
166
|
+
"make_cursor_result",
|
|
167
|
+
"make_page_result",
|
|
168
|
+
# V2
|
|
169
|
+
"AsyncBaseDALV2",
|
|
170
|
+
"AsyncReadDALV2",
|
|
171
|
+
"AsyncWriteDALV2",
|
|
172
|
+
"SQLAExtra",
|
|
173
|
+
"SyncBaseDALV2",
|
|
174
|
+
"SyncReadDALV2",
|
|
175
|
+
"SyncWriteDALV2",
|
|
176
|
+
# repository
|
|
177
|
+
"AsyncSQLAlchemyRepository",
|
|
178
|
+
"SyncSQLAlchemyRepository",
|
|
179
|
+
# lush-dal-protocol ABCs
|
|
180
|
+
"AbstractAsyncAdvancedWriteDAL",
|
|
181
|
+
"AbstractAsyncBaseDAL",
|
|
182
|
+
"AbstractAsyncBatchFieldDAL",
|
|
183
|
+
"AbstractAsyncLockDAL",
|
|
184
|
+
"AbstractAsyncRawSQLDAL",
|
|
185
|
+
"AbstractAsyncReadDAL",
|
|
186
|
+
"AbstractAsyncWriteDAL",
|
|
187
|
+
"AbstractSyncAdvancedWriteDAL",
|
|
188
|
+
"AbstractSyncBaseDAL",
|
|
189
|
+
"AbstractSyncBatchFieldDAL",
|
|
190
|
+
"AbstractSyncLockDAL",
|
|
191
|
+
"AbstractSyncRawSQLDAL",
|
|
192
|
+
"AbstractSyncReadDAL",
|
|
193
|
+
"AbstractSyncWriteDAL",
|
|
147
194
|
)
|