nb2mail
nb2mail copied to clipboard
Update to fix compatibility with nbconvert
There hasn't been a release of this library in a while, and it's not compatible with the latest version of nbconvert.
It takes a few hacks to get nb2mail to work:
# Mime types are not compatible
nb2mail.MailExporter.output_mimetype = "" # Cheating
mail_exporter = nb2mail.MailExporter(
# For some reason nb2mail can't find its template:
template_file=os.path.join(os.path.dirname(nb2mail.__file__), "templates", "mail.tpl"),
)
And there are a lot of warnings:
DeprecationWarning: Keyword `traits` is deprecated in traitlets 5.0, use `per_key_traits` instead
headers = Dict(help="Mail Headers", traits={
DeprecationWarning: 5.x style template file passed '/Users/aandres/source/jetpump2/venv/lib/python3.9/site-packages/nb2mail/templates/mail.tpl'. Use --template-name for the template directory with a index.<ext>.j2 file and/or --template-file to denote a different template.
DeprecationWarning: Passing unrecognized arguments to super(MailExporter).__init__(output_mimetype='').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
super().__init__(**kwargs)
DeprecationWarning: This template is deprecated, please use base/display_priority.j2
warnings.warn(msg, DeprecationWarning)
Do you have a sense of how much of those errors, if fixed, would subsequently break python 2 support? There's still some legacy clients using this.
@nfultz I have no idea. I didn't have in mind python 2 users.
You could potentially tag the new version in setup.py so it drops support for python 2. Then users of python 2 won't pick up the new version automatically.
Hi @0x26res I have applied the fix at: https://github.com/idanre1/nb2mail
@idanre1 thanks for sharing this!