lush-sqlalchemyx 0.1.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.
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.3
2
+ Name: lush-sqlalchemyx
3
+ Version: 0.1.0
4
+ Summary: see README.md
5
+ Author: straydragon
6
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.43
7
+ Requires-Dist: pydantic>=2.11.0,<3.0.0
8
+ Requires-Dist: typing-extensions>=4.12.2
9
+ Requires-Dist: lush-pydanticx>=0.1.0
10
+ Requires-Dist: lush-stdx>=0.1.0
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+
14
+ # lush-sqlalchemyx
15
+
16
+ SQLAlchemy(偏 asyncio) 的一组工具和封装. 这里的东西偏“工程向”: 解决常见的 session 管理、只读会话、以及一些重复写到吐的样板代码.
17
+
18
+ ## 例子
19
+
20
+ 一个最小的异步 MySQL 管理器:
21
+
22
+ ```python
23
+ import asyncio
24
+
25
+ from lush_sqlalchemyx.mgrs.mysql.manager import AsyncMySQLManager
26
+
27
+ async def main() -> None:
28
+ mgr = AsyncMySQLManager("mysql+aiomysql://<user>:<password>@127.0.0.1:3306/<dbname>")
29
+ ok = await mgr.health_check()
30
+ print(ok)
31
+
32
+ await mgr.close()
33
+
34
+
35
+ asyncio.run(main())
36
+ ```
37
+
38
+ ## 开发
39
+
40
+ ```bash
41
+ uv sync -p 3.10 --frozen
42
+ uv run -p 3.10 pytest
43
+ ```
@@ -0,0 +1,30 @@
1
+ # lush-sqlalchemyx
2
+
3
+ SQLAlchemy(偏 asyncio) 的一组工具和封装. 这里的东西偏“工程向”: 解决常见的 session 管理、只读会话、以及一些重复写到吐的样板代码.
4
+
5
+ ## 例子
6
+
7
+ 一个最小的异步 MySQL 管理器:
8
+
9
+ ```python
10
+ import asyncio
11
+
12
+ from lush_sqlalchemyx.mgrs.mysql.manager import AsyncMySQLManager
13
+
14
+ async def main() -> None:
15
+ mgr = AsyncMySQLManager("mysql+aiomysql://<user>:<password>@127.0.0.1:3306/<dbname>")
16
+ ok = await mgr.health_check()
17
+ print(ok)
18
+
19
+ await mgr.close()
20
+
21
+
22
+ asyncio.run(main())
23
+ ```
24
+
25
+ ## 开发
26
+
27
+ ```bash
28
+ uv sync -p 3.10 --frozen
29
+ uv run -p 3.10 pytest
30
+ ```
@@ -0,0 +1,254 @@
1
+ [project]
2
+ name = "lush-sqlalchemyx"
3
+ version = "0.1.0"
4
+ description = "see README.md"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ authors = [{ name = "straydragon" }]
8
+ dependencies = [
9
+ "sqlalchemy[asyncio]>=2.0.43",
10
+ "pydantic>=2.11.0,<3.0.0",
11
+ "typing-extensions>=4.12.2",
12
+ "lush-pydanticx>=0.1.0",
13
+ "lush-stdx>=0.1.0",
14
+ ]
15
+
16
+ [build-system]
17
+ requires = ["uv_build>=0.10.12,<0.11.0"]
18
+ build-backend = "uv_build"
19
+
20
+ [tool.uv]
21
+ package = true
22
+
23
+ [tool.uv.sources]
24
+ lush-pydanticx = { path = "../lush-pydanticx" }
25
+ lush-stdx = { path = "../lush-stdx" }
26
+
27
+ [dependency-groups]
28
+ dev = [
29
+ "jinja2sql>=0.8.0",
30
+ "pytest>=8.4.1",
31
+ "pytest-asyncio>=1.1.0",
32
+ "pytest-cov>=6.2.1",
33
+ "aiosqlite>=0.20.0",
34
+ "fastapi[standard]>=0.117.1",
35
+ ]
36
+
37
+ [tool.pytest.ini_options]
38
+ addopts = "--import-mode=importlib --cov=lush_sqlalchemyx --cov-report=term-missing"
39
+ testpaths = ["tests"]
40
+ asyncio_mode = "auto"
41
+ asyncio_default_fixture_loop_scope = "function"
42
+ asyncio_default_test_loop_scope = "function"
43
+
44
+ [tool.ruff]
45
+ line-length = 140
46
+ indent-width = 4
47
+ target-version = "py310"
48
+
49
+ [tool.ruff.lint]
50
+ fixable = ["F401", "ALL"]
51
+ unfixable = []
52
+
53
+ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
54
+
55
+ select = ["ALL"]
56
+ ignore = [
57
+ # === 代码质量与复杂性 ===
58
+ "C901", # 函数复杂度过高,影响可读性
59
+ "PLR0912", # 函数分支过多,建议重构
60
+ "PLR0913", # 函数参数过多,难以维护
61
+ "PLR0915", # 函数语句过多,建议拆分
62
+ "PLR0911", # 函数返回语句过多,逻辑复杂
63
+ "PLR2004", # 使用魔术数值,建议使用常量
64
+ "SIM108", # 更倾向于使用ifelse表达式,而不是if/else语句
65
+
66
+ # === 类型注解 ===
67
+ "ANN002", # 函数*args参数缺少类型注解
68
+ "ANN003", # 函数**kwargs参数缺少类型注解
69
+ "ANN401", # 使用Any类型,建议使用具体类型
70
+
71
+ # === 函数参数设计 ===
72
+ "FBT001", # 布尔类型位置参数,易混淆
73
+ "FBT002", # 布尔默认值位置参数,易误用
74
+ "N805", # 与pydantic field_validator冲突(cls->self X), 先忽略, 后面再处理
75
+
76
+ # === 异常处理 ===
77
+ "BLE001", # 捕获所有异常,隐藏问题
78
+ "TRY003", # 异常消息应在类中定义
79
+ "TRY004", # 类型检查应抛出TypeError
80
+
81
+ # === 代码简化 ===
82
+ "SIM102", # 可折叠的if语句,简化代码
83
+
84
+ # === 格式规范 ===
85
+ "COM812", # 缺少尾随逗号,影响diff
86
+ "E501", # 行长度过长,影响可读性
87
+
88
+ # === 日志记录 ===
89
+ "G004", # 日志使用f-string,影响性能
90
+
91
+ # === 类型检查优化 ===
92
+ "TC001", # 仅用于类型检查的导入,优化性能
93
+ "TC002", # 仅用于类型检查的导入,优化性能
94
+ "TC003", # 仅用于类型检查的导入,优化性能
95
+
96
+ # === 代码清理 ===
97
+ "ERA001", # 注释掉的代码,应删除
98
+
99
+ # === 私有成员访问 ===
100
+ "SLF001", # 访问私有成员,破坏封装
101
+
102
+ # === 日期时间处理 ===
103
+ "DTZ001", # datetime缺少时区信息
104
+ "DTZ005", # datetime.now()缺少时区
105
+
106
+ # === 调试代码 ===
107
+ "T201", # print语句调试代码,生产环境禁用
108
+
109
+ # === T O D O管理 ===
110
+ "TD002", # 缺少作者信息
111
+ "TD003", # 缺少问题链接
112
+
113
+ # === 其他 ===
114
+ "D", # 文档字符串相关规则
115
+ "EM", # 错误消息相关规则
116
+ ]
117
+
118
+ [tool.ruff.lint.per-file-ignores]
119
+ "tests/**/*.py" = [
120
+ # === 测试代码质量 ===
121
+ "B011", # assert False应改为raise AssertionError
122
+ "B008", # 函数调用作为默认参数
123
+ "ARG001", # 未使用的函数参数
124
+ "ARG002", # 未使用的方法参数
125
+ "ARG005", # lambda中未使用的参数
126
+ "F841", # 未使用的变量
127
+ "B018", # 无用的表达式
128
+ "N806", # 函数中非小写变量名
129
+ "W293", # 空行包含空格
130
+ "N802", # 函数名不规范
131
+ "PERF401", # 性能相关
132
+ "PT", # assert 相关
133
+
134
+ # === 测试安全相关 ===
135
+ "S101", # assert语句(测试中使用)
136
+ "S105", # 硬编码密码字符串
137
+ "S201", # Flask debug=True
138
+ "S301", # 可疑的pickle使用
139
+ "S311", # 非加密安全的随机数
140
+
141
+ # === 测试异常处理 ===
142
+ "BLE001", # 捕获所有异常
143
+ "B017", # assertRaises捕获Exception
144
+ "PT011", # pytest.raises缺少match参数
145
+ "PT017", # except中的assert语句
146
+ "EM101", # 异常中的原始字符串
147
+
148
+ # === 测试代码复杂度 ===
149
+ "C901", # 函数复杂度过高
150
+ "PLR2004", # 魔术数值
151
+
152
+ # === 测试导入相关 ===
153
+ "PLC0415", # 函数内import语句
154
+ "ANN", # 类型注解(测试中宽松)
155
+ "TC", # 类型检查的导入
156
+
157
+ # === 测试参数设计 ===
158
+ "FBT001", # 布尔类型位置参数
159
+ "FBT002", # 布尔默认值位置参数
160
+ "FBT003", # 布尔位置参数调用
161
+
162
+ # === 测试异常处理 ===
163
+ "TRY003", # 异常消息定义
164
+
165
+ # === 测试代码简化 ===
166
+ "SIM117", # 多个连续的with语句
167
+
168
+ # === 测试格式规范 ===
169
+ "E501", # 行长度过长
170
+
171
+ # === 测试日志处理 ===
172
+ "G004", # 日志使用f-string
173
+
174
+ # === 测试调试代码 ===
175
+ "T201", # print语句
176
+
177
+ # === 测试文档相关 ===
178
+ "D", # 文档字符串
179
+
180
+ # === 测试私有访问 ===
181
+ "SLF001", # 私有成员访问
182
+
183
+ # === 测试Unicode ===
184
+ "RUF001", # 模糊的Unicode字符
185
+
186
+ # === 测试路径处理 ===
187
+ "PTH", # pathlib相关规则
188
+
189
+ # === 测试日期时间 ===
190
+ "DTZ001", # datetime缺少时区
191
+ "DTZ005", # datetime.now()缺少时区
192
+
193
+ # === 测试代码清理 ===
194
+ "ERA001", # 注释掉的代码
195
+
196
+ "RUF",
197
+ ]
198
+
199
+ [tool.ruff.format]
200
+ quote-style = "double"
201
+ indent-style = "space"
202
+ skip-magic-trailing-comma = false
203
+ line-ending = "auto"
204
+ docstring-code-format = true
205
+ docstring-code-line-length = "dynamic"
206
+
207
+ # ============================================================================
208
+ # basedpyright 配置 - 独立包配置
209
+ # ============================================================================
210
+ [tool.basedpyright]
211
+ pythonVersion = "3.10"
212
+
213
+ reportUnannotatedClassAttribute = "none"
214
+ reportUnreachable = "none"
215
+ reportUnnecessaryIsInstance = "none"
216
+ reportAny = "none"
217
+ reportExplicitAny = "none"
218
+ reportConstantRedefinition = "none"
219
+ reportUnnecessaryComparison = "none"
220
+
221
+ [[tool.basedpyright.executionEnvironments]]
222
+ root = "tests"
223
+ reportUnusedCallResult = false
224
+ reportUnknownArgumentType = false
225
+ reportUnknownVariableType = false
226
+ reportUnknownMemberType = false
227
+ reportMissingParameterType = false
228
+ reportUnknownParameterType = false
229
+ reportArgumentType = false
230
+ reportCallIssue = false
231
+ reportReturnType = false
232
+ reportUnusedVariable = false
233
+ reportUnusedImport = false
234
+ reportUnusedFunction = false
235
+ reportUnusedParameter = false
236
+ reportPrivateUsage = false
237
+ reportIncompatibleVariableOverride = false
238
+ reportIncompatibleMethodOverride = false
239
+ reportImplicitAbstractClass = false
240
+ reportAbstractUsage = false
241
+ reportExplicitAny = "none"
242
+ reportAny = "none"
243
+ reportUnnecessaryTypeIgnoreComment = false
244
+ reportMissingTypeArgument = false
245
+ reportOptionalMemberAccess = false
246
+ reportAttributeAccessIssue = "none"
247
+ reportGeneralTypeIssues = false
248
+ reportOperatorIssue = false
249
+ reportIndexIssue = false
250
+ reportInvalidTypeArguments = "none"
251
+
252
+
253
+ [[tool.basedpyright.executionEnvironments]]
254
+ root = "src"