Skip to main content

scan_dynamic_dispatch_in_python

Function scan_dynamic_dispatch_in_python 

Source
pub fn scan_dynamic_dispatch_in_python(
    file: &str,
    source: &str,
) -> Vec<DynamicDispatchHint>
Expand description

Plan L t-005: scan Python source for call patterns the static call-graph walker can’t resolve. Returns one hint per detected site so the indexer can surface a warning. The patterns we flag are deliberately conservative — only the ones that are unambiguously dynamic dispatch:

  • getattr(obj, "name")(args) and getattr(obj, name_var)(args) — runtime attribute lookup feeding a call.
  • __getattr__ / __getattribute__ method definitions — the class promises to resolve unknown attributes at runtime.

We deliberately do NOT flag plain getattr(obj, "name") (no trailing call) — that’s a read, not a dispatch, and gets resolved by the property/attribute pass.

Detection runs against the masked source (Plan L t-002) so a # getattr(...) in a comment doesn’t generate a phantom warning.