dspy/direct-forward-call
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| DSPy | warning | none, edit by hand | All versions |
Calling .forward(...) directly on a dspy.Module or predictor skips Module.__call__, which breaks callbacks, MLflow tracing, dspy.track_usage, and optimizer trace capture.
result = self.respond.forward(question=question)result = self.respond(question=question)What the rule reports
Section titled “What the rule reports”Attribute calls to .forward(...) on files that import dspy, excluding super().forward(...).
How to fix it
Section titled “How to fix it”Invoke the sub-module or predictor directly with module(...) so DSPy runs __call__.
Diagnostic message
Section titled “Diagnostic message”Calling .forward(...) directly bypasses dspy.Module.__call__ hooks, MLflow tracing, usage tracking, and optimizer trace capture. Call the module directly instead.See all rules in the DSPy pack.