When a Python class inherits from a base class imported from another file, the AST extractor fails to emit an inherits edge. Instead it produces a weaker uses [INFERRED] edge pointing at the import line rather than the class definition.
Repro:
# module_a.py
class BaseDriver:
...
# module_b.py
from module_a import BaseDriver
class ChildDriver(BaseDriver): # <-- should produce inherits [EXTRACTED]
...
Actual: ChildDriver --uses [INFERRED]--> BaseDriver (at import line)
Expected: ChildDriver --inherits [EXTRACTED]--> BaseDriver (at class def line)
Same-file inheritance is handled correctly. The issue is that the extractor doesn't resolve imported names back to their class node when the base class comes from another module.
Measurement on a ~900-file Python codebase:
- 820 inheritance relationships found via ast.ClassDef.bases
- 389 (47%) correctly emitted as inherits edges (same-file or simple cases)
- 431 (53%) missing, represented only as uses [INFERRED]
Impact:
- graphify path between parent and child classes routes through unrelated intermediate nodes instead of showing the direct inheritance chain
- Community detection separates parent/child classes that should cluster together
- Driver/plugin hierarchies with deep cross-file inheritance chains are especially affected
Environment: graphify 0.9.42, Python 3.12, Windows
When a Python class inherits from a base class imported from another file, the AST extractor fails to emit an inherits edge. Instead it produces a weaker uses [INFERRED] edge pointing at the import line rather than the class definition.
Repro:
Actual: ChildDriver --uses [INFERRED]--> BaseDriver (at import line)
Expected: ChildDriver --inherits [EXTRACTED]--> BaseDriver (at class def line)
Same-file inheritance is handled correctly. The issue is that the extractor doesn't resolve imported names back to their class node when the base class comes from another module.
Measurement on a ~900-file Python codebase:
Impact:
Environment: graphify 0.9.42, Python 3.12, Windows