@descryy/adapter-python 0.2.0 → 0.3.0
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/LICENSE +8 -0
- package/dist/adapter.d.ts +13 -20
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +91 -114
- package/dist/adapter.js.map +1 -1
- package/dist/client.d.ts +22 -41
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +35 -62
- package/dist/client.js.map +1 -1
- package/dist/extract.d.ts +16 -0
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +81 -5
- package/dist/extract.js.map +1 -1
- package/dist/extract.py +45 -4
- package/dist/graphql.d.ts +57 -123
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +62 -130
- package/dist/graphql.js.map +1 -1
- package/dist/module.d.ts +23 -42
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +26 -47
- package/dist/module.js.map +1 -1
- package/dist/orm.d.ts +31 -46
- package/dist/orm.d.ts.map +1 -1
- package/dist/orm.js +53 -89
- package/dist/orm.js.map +1 -1
- package/dist/pydantic.d.ts +76 -91
- package/dist/pydantic.d.ts.map +1 -1
- package/dist/pydantic.js +106 -99
- package/dist/pydantic.js.map +1 -1
- package/dist/routes.d.ts +46 -93
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +65 -129
- package/dist/routes.js.map +1 -1
- package/package.json +14 -5
- package/src/extract.py +45 -4
package/dist/client.js
CHANGED
|
@@ -5,29 +5,19 @@
|
|
|
5
5
|
* API_ROUTE ──SERVES_API──▶ API_ENDPOINT ◀──USES_API── caller
|
|
6
6
|
* ```
|
|
7
7
|
*
|
|
8
|
-
* `routes.ts` produces the provider half
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* `routes.ts` produces the provider half; this the consumer half — until it
|
|
9
|
+
* existed, `adapter-python` declared no `USES_API` and golden 08 was skipped
|
|
10
|
+
* as declared incapacity (DEC-043).
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Provenance, never the name: `requests.get(...)` is only an HTTP call when
|
|
13
|
+
* `requests` resolves through this file's imports. `client.get()` is the
|
|
14
|
+
* commonest false positive here — every Django/Flask test suite calls
|
|
15
|
+
* `client.get("/orders/1")` on a test client making no HTTP request at all
|
|
16
|
+
* (1,970 such sites in django, 310 in flask, against one file in either that
|
|
17
|
+
* imports `requests`).
|
|
13
18
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* package. A local object called `requests`, or a `client.get()` on something
|
|
17
|
-
* this reader cannot trace, is not one — and `client.get()` is the single most
|
|
18
|
-
* common false positive available here, because every Django and Flask test
|
|
19
|
-
* suite in existence calls `client.get("/orders/1")` on a **test client** that
|
|
20
|
-
* makes no HTTP request at all. A census of the reference set found 1,970 such
|
|
21
|
-
* call sites in `django` and 310 in `flask`, against **one** file in either that
|
|
22
|
-
* imports `requests`. Matching on the verb name would have produced 2,280 edges
|
|
23
|
-
* to endpoints nothing serves.
|
|
24
|
-
*
|
|
25
|
-
* ## What is refused
|
|
26
|
-
*
|
|
27
|
-
* A path that is not a literal or an f-string · a path that is not
|
|
28
|
-
* repository-relative, which is an outbound call to somebody else's service and
|
|
29
|
-
* has no route on this side of the join · a `request()` whose verb is not a
|
|
30
|
-
* literal. Each is a ledger row.
|
|
19
|
+
* Refused: a non-literal/non-f-string path, a non-repository-relative path
|
|
20
|
+
* (an outbound call with no route on this side), a non-literal `request()` verb.
|
|
31
21
|
*/
|
|
32
22
|
/** The packages whose module-level verbs are HTTP calls. */
|
|
33
23
|
export const CLIENT_MODULES = new Set(["requests", "httpx", "aiohttp"]);
|
|
@@ -85,17 +75,12 @@ function diagnoseArgument(text, parameterNames) {
|
|
|
85
75
|
}
|
|
86
76
|
/**
|
|
87
77
|
* An f-string whose first element is an interpolation: `f"{BASE}/orders/{id}"`.
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* precision draw could have said so — there were no edges to sample.
|
|
95
|
-
*
|
|
96
|
-
* Returns the base expression as written and the remainder as a template. The
|
|
97
|
-
* remainder must begin with `/`, because `f"{base}orders"` is a base whose own
|
|
98
|
-
* trailing slash decides the path and this reader cannot see it.
|
|
78
|
+
* This is the shape a Python service actually writes — until added, the
|
|
79
|
+
* reader refused every one as "not a literal": across five reference repos,
|
|
80
|
+
* 283 module-level verb calls, zero repository-relative literals, 78 of
|
|
81
|
+
* this form. Returns the base as written and the remainder as a template;
|
|
82
|
+
* the remainder must start with `/`, since a base's own trailing slash
|
|
83
|
+
* would otherwise decide the path invisibly.
|
|
99
84
|
*/
|
|
100
85
|
export function assemblyOfSource(raw) {
|
|
101
86
|
const text = raw.trim();
|
|
@@ -129,15 +114,11 @@ function pathOfBase(value) {
|
|
|
129
114
|
}
|
|
130
115
|
/**
|
|
131
116
|
* A path argument's source text as a template, or `undefined`.
|
|
132
|
-
*
|
|
133
|
-
* `
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* Deliberately narrow: one string, no implicit concatenation, no `%` or
|
|
139
|
-
* `.format()`. Each of those is a path assembled somewhere else, and a template
|
|
140
|
-
* guessed from half of it is an endpoint that does not exist.
|
|
117
|
+
* `f"/orders/{order_id}"` -> `/orders/{param}`, matching what
|
|
118
|
+
* `normaliseEndpointPath` produces from the provider side, or the join
|
|
119
|
+
* doesn't happen. Deliberately narrow — one string, no concatenation, no
|
|
120
|
+
* `%`/`.format()` — since a template guessed from half an assembly is an
|
|
121
|
+
* endpoint that doesn't exist.
|
|
141
122
|
*/
|
|
142
123
|
export function templateOfSource(raw) {
|
|
143
124
|
const text = raw.trim();
|
|
@@ -227,8 +208,7 @@ functionParams = new Map()) {
|
|
|
227
208
|
let method = CLIENT_VERBS.get(attribute);
|
|
228
209
|
let pathIndex = 0;
|
|
229
210
|
if (method === undefined) {
|
|
230
|
-
// `requests.request("POST", url)
|
|
231
|
-
// it is a fact only when it is written as a literal.
|
|
211
|
+
// `requests.request("POST", url)`: the verb is a fact only when literal.
|
|
232
212
|
if (attribute !== "request")
|
|
233
213
|
continue;
|
|
234
214
|
const verb = call.hasLiterals[0] === true ? String(call.literals[0]) : undefined;
|
|
@@ -250,12 +230,10 @@ functionParams = new Map()) {
|
|
|
250
230
|
if (rawPath === undefined)
|
|
251
231
|
continue;
|
|
252
232
|
let path;
|
|
253
|
-
// `url = f"{BASE}/orders"` two lines above `requests.get(url)`. One hop
|
|
254
|
-
// only
|
|
255
|
-
//
|
|
256
|
-
//
|
|
257
|
-
// bound twice in one scope is not resolved either — the last write wins in
|
|
258
|
-
// this map and that is a guess, so the shape is left to the ledger.
|
|
233
|
+
// `url = f"{BASE}/orders"` two lines above `requests.get(url)`. One hop
|
|
234
|
+
// only, and the local must be bound in the same scope — two functions
|
|
235
|
+
// each binding `url` are two different paths, and merging them would
|
|
236
|
+
// attach a caller to an endpoint it never reaches.
|
|
259
237
|
const source = call.hasLiterals[pathIndex] === true
|
|
260
238
|
? undefined
|
|
261
239
|
: localStrings.get(`${call.scope.join(".")}::${rawPath.trim()}`);
|
|
@@ -264,12 +242,10 @@ functionParams = new Map()) {
|
|
|
264
242
|
path = String(call.literals[pathIndex]);
|
|
265
243
|
}
|
|
266
244
|
else {
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
// `
|
|
270
|
-
//
|
|
271
|
-
// refusal that is not merely wrong but points at the wrong work. Every one
|
|
272
|
-
// of the 78 base-carrying calls in the reference set landed there.
|
|
245
|
+
// Assembly tried before the plain template — order is the whole fix.
|
|
246
|
+
// `templateOfSource` alone reads `f"{BASE}/orders/{id}"` as
|
|
247
|
+
// `{param}/orders/{param}`, fails the leading-slash test, and files as
|
|
248
|
+
// "an absolute URL" — all 78 base-carrying calls in the reference set landed there.
|
|
273
249
|
const assembly = assemblyOfSource(written);
|
|
274
250
|
if (assembly !== undefined) {
|
|
275
251
|
const value = constants.get(assembly.base);
|
|
@@ -285,9 +261,8 @@ functionParams = new Map()) {
|
|
|
285
261
|
continue;
|
|
286
262
|
}
|
|
287
263
|
if (resolved.external) {
|
|
288
|
-
// DEC-014 makes an endpoint fileless and host-free, so
|
|
289
|
-
//
|
|
290
|
-
// join this caller to a local route it never reaches.
|
|
264
|
+
// DEC-014 makes an endpoint fileless and host-free, so Stripe's
|
|
265
|
+
// `/v1/charges` and a local one would collide as one node.
|
|
291
266
|
refusals.push({
|
|
292
267
|
file,
|
|
293
268
|
line: call.line,
|
|
@@ -305,10 +280,8 @@ functionParams = new Map()) {
|
|
|
305
280
|
}
|
|
306
281
|
}
|
|
307
282
|
if (path === undefined) {
|
|
308
|
-
// A bare name gets its own row
|
|
309
|
-
//
|
|
310
|
-
// literal" files them with genuinely opaque paths — one number for two
|
|
311
|
-
// populations, only one of which is reachable by further work.
|
|
283
|
+
// A bare name gets its own row: 73 of 283 reference calls pass `url`
|
|
284
|
+
// assembled earlier, distinct from genuinely opaque paths.
|
|
312
285
|
const bare = /^[A-Za-z_][A-Za-z0-9_.]*$/.test(rawPath.trim());
|
|
313
286
|
refusals.push({
|
|
314
287
|
file,
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAE7F,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC;IAC/D,SAAS;IACT,QAAQ;IACR,aAAa;IACb,eAAe;CAChB,CAAC,CAAC;AAEH,qDAAqD;AACrD,MAAM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,CAAC;YACH,SAAS;QACX,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,wEAAwE;YACxE,uDAAuD;YACvD,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI;gBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE,qBAAqB;gBAC7B,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,cAAc;aAC7B,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,KAAK,CAAC,IAAI,CAAC;YACT,IAAI;YACJ,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM;YACN,IAAI;YACJ,OAAO;YACP,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,GAAG,QAAQ,IAAI,SAAS,EAAE;SACnC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC"}
|
package/dist/extract.d.ts
CHANGED
|
@@ -111,6 +111,20 @@ interface PyInstantiation {
|
|
|
111
111
|
readonly scope: readonly string[];
|
|
112
112
|
readonly line: number;
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* A local variable's own type annotation — `org: Organization | None = await
|
|
116
|
+
* get_org_for_user(...)` — as opposed to `PyInstantiation`, which only sees a
|
|
117
|
+
* bare constructor call on the right-hand side. `annotation` is the raw
|
|
118
|
+
* annotation text (not a single resolved type name), read through the same
|
|
119
|
+
* `typeNamesIn` + "exactly one candidate" discipline `parameterAnnotatedType`
|
|
120
|
+
* already applies to a parameter's own annotation.
|
|
121
|
+
*/
|
|
122
|
+
interface PyLocalAnnotation {
|
|
123
|
+
readonly local: string;
|
|
124
|
+
readonly annotation: string | null;
|
|
125
|
+
readonly scope: readonly string[];
|
|
126
|
+
readonly line: number;
|
|
127
|
+
}
|
|
114
128
|
/**
|
|
115
129
|
* A module-level type alias (DEC-069), already classified on the Python side —
|
|
116
130
|
* `rule` records *which* admission rule accepted it, so a surprising node can be
|
|
@@ -141,6 +155,8 @@ interface PyFile {
|
|
|
141
155
|
readonly imports: readonly ImportRecord[];
|
|
142
156
|
readonly references: readonly PyReference[];
|
|
143
157
|
readonly instantiations: readonly PyInstantiation[];
|
|
158
|
+
/** A local variable's own annotation, function-body scope only. Optional so an older recording still parses. */
|
|
159
|
+
readonly localAnnotations?: readonly PyLocalAnnotation[];
|
|
144
160
|
readonly valueRefs: readonly PyValueRef[];
|
|
145
161
|
/** Optional so a recording made before DEC-069 still parses. */
|
|
146
162
|
readonly aliases?: readonly PyAlias[];
|
package/dist/extract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAUL,KAAK,MAAM,EACX,KAAK,MAAM,EAGX,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAiC,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAUL,KAAK,MAAM,EACX,KAAK,MAAM,EAGX,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAiC,KAAK,YAAY,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B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C;AAoKD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClG,UAAU,CAuCZ;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,UAAU,CAi2EvD"}
|
package/dist/extract.js
CHANGED
|
@@ -34,7 +34,7 @@ import { databaseTableNodesFromModel, edgeId, endpointQsp, isTypeLikeNodeType, n
|
|
|
34
34
|
import { importRoots, modulePathOf, moduleNameOf, resolveImport, } from "./module.js";
|
|
35
35
|
import { DECLARATIVE_BASE_FACTORIES, ORM_BASE_MODULES, isFrameworkBaseName, ormShapeOf, } from "./orm.js";
|
|
36
36
|
import { globToRegExp, PYTEST_DEFAULTS } from "./pytest-config.js";
|
|
37
|
-
import { drfShapeOf, dtoShapeOf, isDrfSerializerRoot, isPydanticRoot, isValidatorDecorator, } from "./pydantic.js";
|
|
37
|
+
import { drfShapeOf, dtoShapeOf, isDrfSerializerRoot, isPydanticRoot, isValidatorDecorator, PYDANTIC_MODEL_MEMBERS, } from "./pydantic.js";
|
|
38
38
|
import { DRF_ACTIONS, drfRegisterCallsIn, drfRouterLocalsIn, djangoUrlEntriesIn, HTTP_METHODS, isApplicationRouter, joinPath, mountsIn, odooRouteFromDecorator, routeFromDecorator, routersIn, } from "./routes.js";
|
|
39
39
|
import { GRAPHQL_METHOD, fieldFromMethod, fieldsFromAttributes, operationPath, schemaDeclsIn, } from "./graphql.js";
|
|
40
40
|
import { clientCallsIn, clientLocalsIn } from "./client.js";
|
|
@@ -1137,6 +1137,49 @@ export function extract(input) {
|
|
|
1137
1137
|
.filter((target) => target !== undefined && isTypeLikeNodeType(target.type));
|
|
1138
1138
|
return candidates.length === 1 ? candidates[0] : undefined;
|
|
1139
1139
|
}
|
|
1140
|
+
const localAnnotationIndex = new Map();
|
|
1141
|
+
const localAnnotationsOf = (file, local) => {
|
|
1142
|
+
let index = localAnnotationIndex.get(file);
|
|
1143
|
+
if (index === undefined) {
|
|
1144
|
+
index = new Map();
|
|
1145
|
+
for (const entry of input.parsed.files[file]?.localAnnotations ?? []) {
|
|
1146
|
+
const bucket = index.get(entry.local);
|
|
1147
|
+
if (bucket === undefined)
|
|
1148
|
+
index.set(entry.local, [entry]);
|
|
1149
|
+
else
|
|
1150
|
+
bucket.push(entry);
|
|
1151
|
+
}
|
|
1152
|
+
localAnnotationIndex.set(file, index);
|
|
1153
|
+
}
|
|
1154
|
+
return index.get(local) ?? [];
|
|
1155
|
+
};
|
|
1156
|
+
/**
|
|
1157
|
+
* A local variable's *own* type annotation — `org: Organization | None =
|
|
1158
|
+
* await get_org_for_user(...)` inside a function body. Neither
|
|
1159
|
+
* `instantiatedType` (a bare constructor call only) nor
|
|
1160
|
+
* `parameterAnnotatedType` (a function parameter only) can see this shape;
|
|
1161
|
+
* it is the actual root cause of UAT round 4's missed defect
|
|
1162
|
+
* (`sherpa-backend`'s `src/apis/reviews.py`: `org` is a local, not a
|
|
1163
|
+
* parameter, and its annotation was never read at all).
|
|
1164
|
+
*
|
|
1165
|
+
* Same scope discipline as `instantiatedType` — innermost enclosing scope
|
|
1166
|
+
* wins over a module-level annotation of the same name — and the same
|
|
1167
|
+
* "exactly one type-like candidate" discipline `parameterAnnotatedType`
|
|
1168
|
+
* already applies: `Optional[X]`, `X | None` and `Union[X, Y]` all still
|
|
1169
|
+
* resolve to nothing where more than one type-like name survives.
|
|
1170
|
+
*/
|
|
1171
|
+
function localAnnotatedType(file, scopePath, local) {
|
|
1172
|
+
const scopeKey = scopePath.join(".");
|
|
1173
|
+
const inScope = localAnnotationsOf(file, local).filter((a) => a.scope.length === 0 || a.scope.join(".") === scopeKey);
|
|
1174
|
+
const chosen = inScope.find((a) => a.scope.length > 0 && a.scope.join(".") === scopeKey) ??
|
|
1175
|
+
inScope.find((a) => a.scope.length === 0);
|
|
1176
|
+
if (chosen === undefined)
|
|
1177
|
+
return undefined;
|
|
1178
|
+
const candidates = typeNamesIn(chosen.annotation)
|
|
1179
|
+
.map((name) => followName(file, name))
|
|
1180
|
+
.filter((target) => target !== undefined && isTypeLikeNodeType(target.type));
|
|
1181
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
1182
|
+
}
|
|
1140
1183
|
/**
|
|
1141
1184
|
* Is "this attribute is not declared" a claim this adapter can actually
|
|
1142
1185
|
* stand behind for this type?
|
|
@@ -1180,6 +1223,28 @@ export function extract(input) {
|
|
|
1180
1223
|
return baseChainIsFieldFree(receiverType.file, leaf);
|
|
1181
1224
|
});
|
|
1182
1225
|
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Is this a read of `BaseModel`'s own surface, reached through a
|
|
1228
|
+
* Pydantic-classified receiver (the same classification
|
|
1229
|
+
* `attributeExistenceIsProvable` uses, not SQLAlchemy's)?
|
|
1230
|
+
*
|
|
1231
|
+
* `baseChainIsFieldFree` treats any unresolvable base as field-free —
|
|
1232
|
+
* correct for SQLAlchemy's `DeclarativeBase` marker, but not for
|
|
1233
|
+
* `BaseModel`, which is equally unresolvable-in-repo yet has a real,
|
|
1234
|
+
* stable member set of its own (`model_dump`, `model_fields_set`, ...).
|
|
1235
|
+
* Rather than changing `baseChainIsFieldFree` itself — which would also
|
|
1236
|
+
* change the SQLAlchemy path, and that path's assumption is correct —
|
|
1237
|
+
* this is checked narrowly at the one call site that turns "not a
|
|
1238
|
+
* declared field" into a reported `unresolvedFields` fact.
|
|
1239
|
+
*/
|
|
1240
|
+
function isPydanticModelMember(receiverType, name) {
|
|
1241
|
+
if (!PYDANTIC_MODEL_MEMBERS.has(name))
|
|
1242
|
+
return false;
|
|
1243
|
+
const orm = ormShapes.get(receiverType.id);
|
|
1244
|
+
if (orm !== undefined)
|
|
1245
|
+
return false; // SQLAlchemy (or another ORM) — untouched, not this path
|
|
1246
|
+
return dtoShapes.has(receiverType.id) && isPydanticClass(receiverType.file, receiverType.declaration.path[0] ?? "");
|
|
1247
|
+
}
|
|
1183
1248
|
/**
|
|
1184
1249
|
* Walks a class's own base chain, and is safe to "see through" only where
|
|
1185
1250
|
* every hop is either external (nothing this run declares — the
|
|
@@ -2354,11 +2419,15 @@ export function extract(input) {
|
|
|
2354
2419
|
if (container === undefined || container.type !== "FUNCTION")
|
|
2355
2420
|
continue;
|
|
2356
2421
|
// A local instantiation (`org = Organization()`) first, a parameter's
|
|
2357
|
-
// own annotation (`def get(org: Organization)`) second
|
|
2358
|
-
//
|
|
2359
|
-
// `
|
|
2422
|
+
// own annotation (`def get(org: Organization)`) second, a local
|
|
2423
|
+
// variable's own annotation (`org: Organization | None = await
|
|
2424
|
+
// get_org_for_user(...)`) third — the ground truth this pass exists to
|
|
2425
|
+
// catch is the third shape (`sherpa-backend`'s `src/apis/reviews.py`),
|
|
2426
|
+
// which neither `instantiatedType` nor `parameterAnnotatedType` alone
|
|
2427
|
+
// has ever been able to see.
|
|
2360
2428
|
const receiverType = instantiatedType(file, reference.scope, reference.receiver) ??
|
|
2361
|
-
parameterAnnotatedType(container, reference.receiver)
|
|
2429
|
+
parameterAnnotatedType(container, reference.receiver) ??
|
|
2430
|
+
localAnnotatedType(file, reference.scope, reference.receiver);
|
|
2362
2431
|
if (receiverType === undefined)
|
|
2363
2432
|
continue;
|
|
2364
2433
|
// **A mapped column is a declared member, and `fields` cannot see one.**
|
|
@@ -2371,6 +2440,13 @@ export function extract(input) {
|
|
|
2371
2440
|
(ormShapes.get(receiverType.id)?.fields ?? []).some((f) => f.name === reference.name);
|
|
2372
2441
|
if (!declaresField && !attributeExistenceIsProvable(receiverType))
|
|
2373
2442
|
continue;
|
|
2443
|
+
// `BaseModel`'s own members (`model_dump`, `model_fields_set`, ...) are
|
|
2444
|
+
// not a declared field, but they are also not an undeclared one — see
|
|
2445
|
+
// `isPydanticModelMember`. Neither `fields` (a data-field claim) nor
|
|
2446
|
+
// `unresolvedFields` (an absence claim) fits; the read is simply not
|
|
2447
|
+
// evidence either way, so it contributes nothing to this edge.
|
|
2448
|
+
if (!declaresField && isPydanticModelMember(receiverType, reference.name))
|
|
2449
|
+
continue;
|
|
2374
2450
|
const edgeType = isWrite ? "WRITES" : "READS";
|
|
2375
2451
|
const key = `${container.id}|${receiverType.id}|${edgeType}`;
|
|
2376
2452
|
const entry = fieldsByEdge.get(key) ?? {
|