feat: include external class __init__ signatures with transitive type deps in testgen context - #1481
Conversation
…sses in testgen context When generating regression tests, the LLM needs to know how to construct external types used as function parameters. This extends the testgen context to include __init__ signatures from external (site-packages) classes that are directly imported, complementing the existing base class init extraction.
Tests cover: extracting __init__ from site-packages classes (click.Option), skipping project classes, non-classes, already-defined classes, builtins, classes with trivial object.__init__, and empty import scenarios.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review SummaryPrek ChecksAll checks pass. Ruff check and ruff format both pass cleanly. MypyNo new mypy errors introduced by this PR. Pre-existing errors in Code ReviewNo critical bugs, security vulnerabilities, or breaking API changes found. New code in
All edge cases are handled: SyntaxError, ImportError, OSError, missing Minor nits (non-blocking):
Other changes: Import cleanup in Test Coverage
The main file ( Test results: 2384 passed, 57 skipped, 8 failed (all 8 failures are pre-existing in Last updated: 2026-02-13 |
Add BFS-based transitive resolution so that classes referenced in __init__ type annotations of imported external classes are also extracted. This gives the LLM the constructor signatures it needs to instantiate parameter types.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The formatter correctly removed the unused re-exports from parse_test_output.py. Update the test to import directly from codeflash.languages.javascript.parse.
os.path.relpath returns backslashes on Windows. The backslash-to-slash conversion happened after the ./ / ../ prefix check, so the check failed and prepended ./ producing ./../src/... paths. Use Path.as_posix() instead of manual string replacement.
| @@ -32,10 +34,6 @@ | |||
| ) | |||
| from codeflash.verification.coverage_utils import CoverageUtils, JestCoverageUtils | |||
|
|
|||
There was a problem hiding this comment.
✅ Fixed in latest commit
Summary
__init__signatures from directly imported external (site-packages) classes so the LLM can construct them correctly in generated tests__init__type annotations are also extracted (BFS with depth limit of 2)processed_classesset andemitted_namestrackingTest plan
uv run pytest tests/test_code_context_extractor.py)