Skip to content

Fix async and nested scope tracking - #14

Merged
Vashkatsi merged 2 commits into
mainfrom
fix/async-nested-scope
Aug 7, 2026
Merged

Fix async and nested scope tracking#14
Vashkatsi merged 2 commits into
mainfrom
fix/async-nested-scope

Conversation

@Vashkatsi

@Vashkatsi Vashkatsi commented Aug 7, 2026

Copy link
Copy Markdown
Owner

What changed

  • route FunctionDef and AsyncFunctionDef through shared dependency handling
  • restore the enclosing code element after nested functions and classes
  • isolate uncollected nested scopes instead of attributing their dependencies to the parent
  • add focused regression coverage and mark the technical-roadmap item resolved

Root cause

DependencyVisitor did not handle AsyncFunctionDef and stored only one mutable current_code_element. Entering nested definitions either retained the outer element or cleared it permanently, causing missing or misattributed dependencies.

Impact

Top-level async dependencies are now detected, nested sync/async functions and classes own their dependencies, and traversal resumes in the correct enclosing scope. CLI, configuration, and report interfaces are unchanged.

Validation

  • ./.venv/bin/python -m unittest tests.test_dependency_visitor — 9 passed
  • make check — ruff, mypy, pip-audit, 155 tests passed
  • make mutation — 1668 mutants completed; no timeout, suspicious, or untested-file results
  • git diff --check
  • independent high-effort review — no findings

Summary by CodeRabbit

  • Improvements

    • Improved dependency analysis for asynchronous functions and nested functions or classes.
    • Dependencies are now attributed more accurately to the relevant enclosing code element.
  • Documentation

    • Added a detailed technical roadmap covering priorities, validation, integrations, performance, and future features.
    • Added guidance for shell exit-variable naming and handling git diff --no-index results.
    • Linked the verified technical roadmap from the README.
  • Tests

    • Added coverage for asynchronous functions and nested-scope dependency handling.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a354f1c8-dc90-4ec7-9ad4-3e7a81c54f7f

📥 Commits

Reviewing files that changed from the base of the PR and between 92a304c and e0992c5.

📒 Files selected for processing (6)
  • README.md
  • deply/utils/dependency_visitor.py
  • doc/technical-roadmap.md
  • docs/lessons.md
  • docs/superpowers/plans/2026-08-07-async-nested-scope.md
  • tests/test_dependency_visitor.py

📝 Walkthrough

Walkthrough

The change updates DependencyVisitor to preserve nested scopes and process async functions. Tests cover dependency attribution across nested functions and classes. The pull request also adds roadmap, lessons, implementation-plan, and README documentation.

Changes

Dependency scope attribution

Layer / File(s) Summary
Visitor scope handling
deply/utils/dependency_visitor.py
Shared function traversal now handles synchronous and asynchronous functions. Function and class traversal restores the enclosing current_code_element.
Scope regression validation
tests/test_dependency_visitor.py
Tests verify dependency attribution for async functions, nested functions, uncollected nested functions, and nested classes.
Documentation and delivery records
doc/technical-roadmap.md, docs/lessons.md, docs/superpowers/plans/2026-08-07-async-nested-scope.md, README.md
Documentation records the roadmap, implementation plan, verification steps, lessons, and roadmap reference.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PythonAST
  participant DependencyVisitor
  participant FunctionCallCollector
  PythonAST->>DependencyVisitor: traverse function, async function, and class nodes
  DependencyVisitor->>DependencyVisitor: save and restore current_code_element
  DependencyVisitor->>FunctionCallCollector: attribute nested call dependencies
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/async-nested-scope

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Vashkatsi
Vashkatsi marked this pull request as ready for review August 7, 2026 16:53
@Vashkatsi
Vashkatsi merged commit a6f13c0 into main Aug 7, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant