10000 Better MovieWriter init error message by timhoffm · Pull Request #13827 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
Apr 2, 2019

Conversation

timhoffm
Copy link
Member
@timhoffm timhoffm commented Apr 1, 2019

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.

@timhoffm timhoffm added this to the v3.1.0 milestone Apr 1, 2019
# extended with a mixin. This should be clearer in naming
# and description. For now, just give a reasonable error
# message to users.
raise NotImplementedError(
Copy link
Contributor

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

Copy link
Member
@dstansby dstansby left a 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.

@timhoffm timhoffm force-pushed the moviewriter-init-error branch 3 times, most recently from b72c2bf to e93a434 Compare April 1, 2019 20:53
@timhoffm timhoffm force-pushed the moviewriter-init-error branch from e93a434 to 8c068ee Compare April 1, 2019 20:53
@timhoffm
Copy link
Member Author
timhoffm commented Apr 1, 2019

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.

@timhoffm timhoffm dismissed dstansby’s stale review April 1, 2019 20:59

Comment added.

@tacaswell tacaswell merged commit 8714c32 into matplotlib:master Apr 2, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 2, 2019
dstansby added a commit that referenced this pull request Apr 2, 2019
…827-on-v3.1.x

Backport PR #13827 on branch v3.1.x (Better MovieWriter init error message)
@timhoffm timhoffm deleted the moviewriter-init-error branch April 2, 2019 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0