From 0dfec6b132a967f77de0dc51c40573d03fa05723 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Thu, 21 Jul 2022 15:37:10 -0400 Subject: [PATCH] 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 --- zerver/lib/templates.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zerver/lib/templates.py b/zerver/lib/templates.py index e1cc6b899a..ba11237c32 100644 --- a/zerver/lib/templates.py +++ b/zerver/lib/templates.py @@ -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