Skip to content

Two-hop re-exports and aliased imports are not followed #178

Description

@Anandb71

Measured

Fixture files: hard/reexport_base.py, hard/reexport_mid.py, hard/reexport_leaf.py, hard/aliased.py, hard/conditional.py.

original_function is defined once in reexport_base.py and reached four ways:

  1. reexport_leaf.py imports it from reexport_mid.py (two hops)
  2. aliased.pyfrom hard.reexport_base import original_function as renamed
  3. aliased.pyimport hard.reexport_base as base_mod, then base_mod.original_function(n)
  4. conditional.py — imported inside a try/except ImportError

At engine v3.0.0:

original_function   1 caller     (truth: 4)

Why it matters

Re-export barrels (__init__.py, index.ts) and aliased imports are standard in Python and near-universal in TypeScript. Every edge through one is currently lost, which under-reports blast radius on exactly the packages most likely to be widely depended on.

Suggested fix

Follow an import whose target is itself an import (bounded, with cycle detection). Confirm the parser records the local name for as aliases — from x import y as z must key on z.

Reproduce

analyze-local /path/to/arbor-torture --top 25000 > out.txt
python grade.py out.txt   # check D

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions