@descryy/adapter-python 0.3.0 → 0.3.1
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.
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +11 -2
- package/dist/adapter.js.map +1 -1
- package/dist/extract.d.ts +7 -0
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +291 -26
- package/dist/extract.js.map +1 -1
- package/dist/extract.py +14 -0
- package/dist/routes.d.ts +8 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +13 -6
- package/dist/routes.js.map +1 -1
- package/package.json +5 -5
- package/src/extract.py +14 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descryy/adapter-python",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Python adapter. Parses with Python's own ast in one subprocess (DEC-062)
|
|
5
|
+
"description": "Python adapter. Parses with Python's own ast in one subprocess (DEC-062) — no grammar to keep in sync, and annotations arrive as source text.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@descryy/adapter-common": "0.2.0",
|
|
39
|
-
"@descryy/ir": "0.5.
|
|
40
|
-
"@descryy/adapter-openapi": "0.3.
|
|
41
|
-
"@descryy/adapter-sql": "0.3.
|
|
39
|
+
"@descryy/ir": "0.5.1",
|
|
40
|
+
"@descryy/adapter-openapi": "0.3.1",
|
|
41
|
+
"@descryy/adapter-sql": "0.3.1"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/extract.py
CHANGED
|
@@ -183,6 +183,14 @@ def _call_record(node: ast.Call, line: int, scope: list[str] | None = None) -> d
|
|
|
183
183
|
literals: list[object] = []
|
|
184
184
|
names: list[object] = []
|
|
185
185
|
arg_calls: list[object] = []
|
|
186
|
+
# A positional list/tuple of written constants — `@require_http_methods(["POST",
|
|
187
|
+
# "PUT"])`, `@api_view(["POST"])`. `_literal` alone reads only a bare constant, so
|
|
188
|
+
# without this a decorator's own declared verb list would look unreadable and this
|
|
189
|
+
# adapter would default to GET over a method the source names outright. Mirrors
|
|
190
|
+
# `keywordLists` below one argument position over; `None` when the position isn't a
|
|
191
|
+
# list/tuple of constants, never a placeholder for "unreadable" (nothing today reads
|
|
192
|
+
# that distinction for a positional argument).
|
|
193
|
+
arg_lists: list[object] = []
|
|
186
194
|
for argument in node.args:
|
|
187
195
|
read = _literal(argument)
|
|
188
196
|
literals.append(None if read is _OPAQUE else read)
|
|
@@ -195,6 +203,11 @@ def _call_record(node: ast.Call, line: int, scope: list[str] | None = None) -> d
|
|
|
195
203
|
arg_calls.append(
|
|
196
204
|
_call_record(argument, argument.lineno) if isinstance(argument, ast.Call) else None
|
|
197
205
|
)
|
|
206
|
+
if isinstance(argument, (ast.List, ast.Tuple)):
|
|
207
|
+
items = [_literal(element) for element in argument.elts]
|
|
208
|
+
arg_lists.append(items if items and all(item is not _OPAQUE for item in items) else None)
|
|
209
|
+
else:
|
|
210
|
+
arg_lists.append(None)
|
|
198
211
|
|
|
199
212
|
keywords: dict[str, object] = {}
|
|
200
213
|
keywordNames: dict[str, str] = {}
|
|
@@ -236,6 +249,7 @@ def _call_record(node: ast.Call, line: int, scope: list[str] | None = None) -> d
|
|
|
236
249
|
"literals": literals,
|
|
237
250
|
"argNames": names,
|
|
238
251
|
"argCalls": arg_calls,
|
|
252
|
+
"argLists": arg_lists,
|
|
239
253
|
"hasLiterals": [_literal(argument) is not _OPAQUE for argument in node.args],
|
|
240
254
|
"keywords": keywords,
|
|
241
255
|
"keywordNames": keywordNames,
|