Raise NotImplementedError in MovieWriter._args instead of returning it#32067
Raise NotImplementedError in MovieWriter._args instead of returning it#32067jameslin9968 wants to merge 1 commit into
Conversation
MovieWriter._args() is a placeholder meant to be overridden by concrete subclasses. It used `return NotImplementedError(...)` instead of `raise`, so a MovieWriter subclass that forgot to override it would not fail loudly: _run() calls `command = self._args()`, which would silently bind an exception instance and pass it on as if it were the command-line argument list, producing a confusing downstream error instead of the intended 'args needs to be implemented by subclass' message. Add a regression test.
|
Is there a reason to not make this an |
|
Thanks @timhoffm — I tried
This is exactly the case flagged by the existing TODO in So for this PR I have kept the conservative |
3936274 to
6edcbc5
Compare
PR summary
MovieWriter._args()is a placeholder meant to be overridden by concretesubclasses. It used
return NotImplementedError(...)instead ofraise, so aMovieWritersubclass that forgot to override it would not fail loudly:_run()doescommand = self._args(), which would silently bind an exceptioninstance and pass it downstream as if it were the command-line argument list,
producing a confusing error instead of the intended "args needs to be
implemented by subclass" message. This changes
returntoraiseand adds aregression test.
Minimal reproduction of the previous behavior:
Note (per review discussion): making
_argsan@abc.abstractmethodwasconsidered but rejected —
HTMLWriteris a non-subprocessMovieWriterthatnever calls
_run/_argsand has no_args, so an abstractmethod would makeit un-instantiable (18 test failures). A proper fix is the
_run/_argsmixinrefactor already flagged by the source TODO, which is out of scope for this
one-line bugfix.
AI Disclosure
This PR was authored with substantial AI assistance (Claude). AI was used to
localize the issue in
MovieWriter._args, write the one-line fix, and generatethe regression test in
test_animation.py. All changes were run and verifiedlocally: the new test fails without the fix and passes with it, and the full
test_animation.pysuite passes (48 passed / 23 skipped / 0 failed).PR checklist
test_animation.py)