-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Better MovieWriter init error message #13827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/matplotlib/animation.py
Outdated
# extended with a mixin. This should be clearer in naming | ||
# and description. For now, just give a reasonable error | ||
# message to users. | ||
raise NotImplementedError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a TypeError, as that's what you get with ABC:
In [1]: class T(abc.ABC):
...: foo = abc.abstractmethod(lambda self: None)
...:
In [2]: T()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-6d5ec5817329> in <module>
----> 1 T()
TypeError: Can't instantiate abstract class T with abstract methods foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put a small comment in the docstring with the same information as the error message? Otherwise looks good to me.
b72c2bf
to
e93a434
Compare
e93a434
to
8c068ee
Compare
This is quite a mess. There were tests running on instances of the abstract MovieWriter. Fixed to the extent that you cannot instantiate MovieWriter at all, but need to subclass MovieWriter (whether reasonable or not). We do not want users to instantiate MovieWriter, but some tests seem to work with incomplete instances. Needs further sorting out, but beyond this PR. @dstansby Comment added to docstring. |
…827-on-v3.1.x Backport PR #13827 on branch v3.1.x (Better MovieWriter init error message)
PR Summary
From #5403 (comment). Calling
MovieWriter(fps=25)
results in a not quite helpful error message'MovieWriter' object has no attribute 'args_key'
.This is just a quick fix to give a reasonable error message, and get that improved user experience in with 3.1.
A full solution should add a description on the mixin mechanism, and maybe even join AbstractMovieWriter and MovieWriter classes. But that's beyond the scope of this PR.