High-confidence `import_map` collides on common method names
Severity: medium-high — survives a confidence >= 0.9 filter.
from unittest.mock import patch is bound to a REST view's HTTP handler
PkgConfigView.patch with strategy=import_map, confidence=0.95. This is 4 of the
5 misses in the filtered sample — i.e. the dominant residual error once consumers
do filter correctly.
Ask: when a name is imported in the caller's file, prefer that import's target over a same-named method elsewhere in the graph.
Observed on v0.10.8 (build 996bad5fe6fb), macOS arm64, Python monorepo (~36k nodes / ~179k edges). Happy to provide a minimal reproduction repo if useful.
Thank you so much @avigdorsky for this report, and for the exact example and the numbers from your filtered sample. It pointed straight at the root cause.
from unittest.mock import patch names a module outside your project, so the importer could not resolve it. A name-only fallback then bound it to the one project definition called patch (your view's HTTP handler), and every patch(...) call inherited import-level confidence (0.95).
The fix (#2345) follows your suggestion: in Python, an import now binds the name to that import. A symbol from an external module is never matched to a same-named project definition that isn't on the imported module path, either at import time or through the weaker name-matching fallbacks. Imports of your own modules, including re-exports, are unchanged. On django/django this removed about 2,300 such false CALLS edges (e.g. os.path.join → a template filter, json.loads → signing.loads), and every edge we sampled was a real false positive. If you still see leftover cases after upgrading, a minimal repro repo is always welcome. Thanks again!
Thank you again for reporting this, @avigdorsky! The fix is now on main in bedbc0ac (merged via #2345), and it will ship in the next release.