MLC123: ApplyFunction callback returns no mobject on some path¶
qual reports MLC123 when the callback passed to ApplyFunction
provably fails to return a mobject on some normal return path.
ApplyFunction.create_target() calls function(mobject.copy()) and uses
the return value as the transform target (transform.py
ApplyFunction.create_target); a callback that mutates its argument but
returns None — a bare return or falling off the end — or returns a
definite non-mobject breaks the play the moment it begins.
- Default severity:
error - Minimum confidence:
high - Implementation phase:
2 - Fix: none (adding the missing
returnwould be an unsafe edit and is suggested in the message)
The rule resolves lambdas by their exact source span and named arguments
by qualified project-function name, and fires only on a proven
returns_mobject == No: a path returning an untracked value is Maybe
and stays silent, and paths ending in raise never count as a missing
return.
Wrong¶
def push_right(mob):
mob.shift(RIGHT) # falls off the end: returns None
class Demo(Scene):
def construct(self):
square = Square()
self.add(square)
self.play(ApplyFunction(push_right, square))