Files
codegraph/__tests__/fixtures/kernel-parity/torture.py
T
9181dd1ef3 fix(extraction): land upstream declaration initializer walks (#1511) (#1802)
Squash danusha2345's PR #1511 at d282f9e8 onto main 8c9c4761,
preserving its nine non-merge commits and main's existing Unreleased notes.
Calls in Kotlin, Java, TS/JS, Scala, Rust and Python declaration initializers
now retain the owner established by the upstream regression expectations.
Include the upstream CFML, dynamic-dispatch summary and viewer follow-ups.

Linux fail-to-pass validation (Node 22.19.0, rebuilt dist and native kernel):
- Before: TS load belonged to file:app.ts; Python/Kotlin/Scala/Rust calls
  vanished; Java lost the field-lambda, anonymous override and eager calls.
- After: all six languages PASS; 12 native/WASM LF/CRLF parity checks PASS.
- Focused initializer regressions: 10 passed with CODEGRAPH_KERNEL=0 and
  10 passed with the kernel enabled; Kotlin's grammar fallback is recorded.
- Related regression suites: 879 passed, 1 skipped across 15 test files.
- Evidence: /workspace/cg-1510-repro/before and /workspace/cg-1510-repro/after
  (combined test output: after/vitest.log).

Fixes #1510
Supersedes #1511

Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
2026-09-08 17:33:45 -05:00

64 lines
1.4 KiB
Python

"""Python torture fixture — decorators, self fn-refs, imports, shadowing."""
import os, sys
import os.path as osp
from collections import OrderedDict, defaultdict
from .relative import thing
from mypkg.handlers import target_cb
RETRY_LIMITS = {"a": 1}
API_BASE = "https://example.test"
x = compute(RETRY_LIMITS)
class Service(BaseService, mixins.LoggerMixin):
"""Class docs."""
def __init__(self, registry):
self.registry = registry
register(self.on_event)
queue(target_cb)
@staticmethod
def helper(arg):
return transform(arg)
async def run(self):
cfg = self.registry.lookup("x")
limit = RETRY_LIMITS
obj.method_chain().deep(cfg)
", ".join(cfg)
return await fetch(API_BASE)
def on_event(self):
pass
@app.route("/x")
def view():
def inner():
return API_BASE
return inner()
def shadowed():
API_BASE = "local"
return API_BASE
handlers = {"recv": target_cb}
callbacks = [target_cb, view]
# Initializer walks attributed to the assigned name (#693).
INIT_EAGER = helper()
INIT_LAMBDA = lambda: target_cb()
INIT_MAP = {"a": helper()}
init_a, init_b = helper(), view()
# --- call receivers (#1683) ---------------------------------------------------
def bucket_chains(d, k, v):
d.setdefault(k, []).append(v)
d.items().get(k)
make().run()
(lambda: make)()().run()
obj.make().run().again()