-
Notifications
You must be signed in to change notification settings - Fork 317
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
Validate pre and post convert hooks #1438
Conversation
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.
Thanks for this!
nbgrader/converters/base.py
Outdated
@validate('post_convert_hook') | ||
def _validate_post_convert_hook(self, proposal): | ||
value = proposal['value'] | ||
if isinstance(value, string_types): |
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.
nbgrader is python 3 only these days, so I think you can just check against str here (and above as well).
nbgrader/converters/base.py
Outdated
@@ -19,6 +19,8 @@ | |||
from ..nbgraderformat import SchemaTooOldError, SchemaTooNewError | |||
import typing | |||
from nbconvert.exporters.exporter import ResourcesDict | |||
from ipython_genutils.importstring import import_item |
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.
I believe genutils isn't officially supported, and it would probably be better to not need to add a new dependency in any case---could you achieve the same behavior using importlib.import_module
? See https://docs.python.org/3/library/importlib.html
Thanks for pointing out the changes. I think I addressed them with my new commit. |
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.
Great, thanks!
Fixing the problem mentioned in #1376.
If the hooks are given as an import string (see example) they are now properly imported.