templates: Use Dict instead of Mapping for the context parameter.

According to the Django documentation, `Template.render` expects a
`dict`.

See also: https://docs.djangoproject.com/en/4.0/topics/templates/#django.template.backends.base.Template.render.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-21 15:37:10 -04:00 committed by Tim Abbott
parent e950b94ab5
commit 0dfec6b132
1 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import time
from typing import Any, List, Mapping, Optional
from typing import Any, Dict, List, Optional
import markdown
import markdown.extensions.admonition
@ -82,13 +82,15 @@ docs_without_macros = [
@items_tuple_to_dict
@register.filter(name="render_markdown_path", is_safe=True)
def render_markdown_path(
markdown_file_path: str, context: Mapping[str, Any] = {}, pure_markdown: bool = False
markdown_file_path: str, context: Optional[Dict[str, Any]] = None, pure_markdown: bool = False
) -> str:
"""Given a path to a Markdown file, return the rendered HTML.
Note that this assumes that any HTML in the Markdown file is
trusted; it is intended to be used for documentation, not user
data."""
if context is None:
context = {}
# We set this global hackishly
from zerver.lib.markdown.help_settings_links import set_relative_settings_links