From 43ceb384657d3c10df362c55617d0fa4d0c73801 Mon Sep 17 00:00:00 2001 From: Karol Zlot <11590960+karolzlot@users.noreply.github.com> Date: Mon, 6 Jun 2022 23:49:48 +0200 Subject: [PATCH] Add type hints to get_undeclared_template_variables --- docxtpl/template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docxtpl/template.py b/docxtpl/template.py index 4467a09..cb8219d 100644 --- a/docxtpl/template.py +++ b/docxtpl/template.py @@ -6,7 +6,7 @@ Created : 2015-03-12 """ from os import PathLike -from typing import Any, Optional, IO, Union, Dict +from typing import Any, Optional, IO, Union, Dict, Set from .subdoc import Subdoc import functools import io @@ -36,7 +36,7 @@ class DocxTemplate(object): HEADER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" FOOTER_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" - def __init__(self, template_file_or_path: Union[IO[bytes], str, PathLike[str]]): + def __init__(self, template_file_or_path: Union[IO[bytes], str, PathLike[str]]) -> None: self.template_file_or_path = template_file_or_path self.reset_replacements() self.docx = None @@ -324,7 +324,7 @@ class DocxTemplate(object): new_part.load_rel(rel.reltype, rel._target, rel.rId, rel.is_external) self.docx._part._rels[relKey]._target = new_part - def render(self, context: Dict[str, Any], jinja_env: Optional[Environment]=None, autoescape: bool=False): + def render(self, context: Dict[str, Any], jinja_env: Optional[Environment]=None, autoescape: bool=False) -> None: # init template working attributes self.render_init() @@ -722,7 +722,7 @@ class DocxTemplate(object): self.post_processing(output_file_or_path) self.is_saved = True - def get_undeclared_template_variables(self, jinja_env=None): + def get_undeclared_template_variables(self, jinja_env: Optional[Environment]=None) -> Set[str]: self.init_docx() xml = self.get_xml() xml = self.patch_xml(xml)