Python's class-as-value idioms (return SomeClass, x = SomeClass, registry dicts, classes passed as arguments) produced no references edges, so callers/impact on a Django/DRF serializer missed the views that consume it. Three gates dropped them: - return_statement was never dispatched by PYTHON_SPEC (kernel mirrored) - the extraction gate (definedHere) collected function/method names only - resolution accepted function/method targets only (matchFunctionRef + the function_ref import fast path) Capture return_statement for Python (single expression; tuple returns not descended), admit same-file CLASS names to the gate, and accept class targets for Python bare identifiers — scoped to Python so the TS/JS KIND FILTER contract is untouched. The docopt false-positive mechanism behind the function-only rule (lowercase locals vs same-named methods) doesn't transfer: methods stay excluded for bare ids, and the same-file/import gate + unique-or-drop rules still apply. Probed on django-rest-framework (~250 files): 559 new references→class edges, 10/10 sampled genuine (serializer_class = AuthTokenSerializer, the ModelSerializer field-mapping registry, aliases, ctor args, isinstance). EXTRACTION_VERSION 24 → 25. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
f2a5df34de
commit
38580e0b04
@@ -250,7 +250,9 @@ impl<'t> Walker<'t> {
|
||||
target_id_str: NONE_STR,
|
||||
});
|
||||
|
||||
if kind == "function" || kind == "method" {
|
||||
// Classes join the fn-ref gate for Python (#1478): class-as-value is
|
||||
// a first-class idiom (mirrors flushFnRefCandidates' python branch).
|
||||
if kind == "function" || kind == "method" || kind == "class" {
|
||||
self.defined_fn_names.insert(name.to_string());
|
||||
}
|
||||
// captureValueRefScope
|
||||
@@ -711,6 +713,11 @@ impl<'t> Walker<'t> {
|
||||
"keyword_argument" => ("value", "value"),
|
||||
"pair" => ("value", "value"),
|
||||
"list" => ("list", ""),
|
||||
// `return SomeClass` / `return handler` (#1478) — a single
|
||||
// returned expression is a direct named child ('list' shape);
|
||||
// tuple returns sit under expression_list and are not descended
|
||||
// (mirrors PYTHON_SPEC).
|
||||
"return_statement" => ("list", ""),
|
||||
_ => return,
|
||||
};
|
||||
if self.stack.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user