Further mutable-default fix to template-renderer

This commit is contained in:
Matthias 2024-04-19 07:26:35 +02:00
parent 87d50243e2
commit be1e1453da

View File

@ -3,7 +3,7 @@ Jinja2 rendering utils, used to generate new strategy and configurations.
""" """
from typing import Dict from typing import Dict, Optional
def render_template(templatefile: str, arguments: Dict) -> str: def render_template(templatefile: str, arguments: Dict) -> str:
@ -19,11 +19,13 @@ def render_template(templatefile: str, arguments: Dict) -> str:
def render_template_with_fallback(templatefile: str, templatefallbackfile: str, def render_template_with_fallback(templatefile: str, templatefallbackfile: str,
arguments: dict = {}) -> str: arguments: Optional[Dict] = None) -> str:
""" """
Use templatefile if possible, otherwise fall back to templatefallbackfile Use templatefile if possible, otherwise fall back to templatefallbackfile
""" """
from jinja2.exceptions import TemplateNotFound from jinja2.exceptions import TemplateNotFound
if arguments is None:
arguments = {}
try: try:
return render_template(templatefile, arguments) return render_template(templatefile, arguments)
except TemplateNotFound: except TemplateNotFound: