Skip to content

Bug: Respect relative import levels in Python import parsing #22

Description

@eshaanag

What is missing / Why it matters

In backend/features/repo_ingestion/graph_builder.py, extract_python_imports parses Python source code using AST. When it encounters a relative import (e.g., from .database import get_db), it only extracts node.module (which evaluates to "database" without the dot prefix) and completely ignores node.level (which indicates the relative nesting depth). As a result, the resolver receives "database" instead of ".database", causing it to fail relative import resolution and misinterpret import edges.

Acceptance Criteria

  • Modify extract_python_imports to inspect node.level of ast.ImportFrom nodes. Prepend a corresponding number of dots . based on level to the module string before yielding it.
  • Verify using pytest that relative Python imports are correctly resolved to their target files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingintermediateIntermediate complexity issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions