Skip to content
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

relace contextfilter with pass_context #127

Merged
merged 3 commits into from
Jun 28, 2022

Conversation

YuxingW
Copy link

@YuxingW YuxingW commented Jun 24, 2022

contextfilter is deprecated in jinja2 and can be replaced by pass_context
jupyter/nbconvert#1568
Can we please replace contextfilter in filter_plugins/filters.py? Otherwise there is an error with new jinja2:
michaelrigart.interfaces/filter_plugins/filters.py) as it seems to be invalid: module 'jinja2' has no attribute 'contextfilter'

Copy link
Collaborator

@markgoddard markgoddard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@@ -128,7 +128,7 @@ def _interface_check(context, interface, interface_type=None):
return _pass()


@jinja2.contextfilter
@jinja2.pass_context
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks on versions of Jinja2 older than 3.0.0. What I've done elsewhere is this:

# NOTE: jinja2 3.1.0 dropped contextfilter in favour of pass_context.
try:
    from jinja2 import pass_context
except ImportError:
    from jinja2 import contextfilter as pass_context

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is something I am also in favor of, thanks!

Copy link
Collaborator

@markgoddard markgoddard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@markgoddard markgoddard merged commit bc94897 into michaelrigart:master Jun 28, 2022
@YuxingW
Copy link
Author

YuxingW commented Jun 28, 2022

Cool, thanks for the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants