From 416729dddc9a362d6747630e292001ecc26b4cec Mon Sep 17 00:00:00 2001 From: Eric Lapouyade Date: Tue, 15 Jul 2025 15:46:03 +0200 Subject: [PATCH] Run black on template.py --- docxtpl/template.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docxtpl/template.py b/docxtpl/template.py index 2e12d53..7613a2f 100644 --- a/docxtpl/template.py +++ b/docxtpl/template.py @@ -887,34 +887,36 @@ class DocxTemplate(object): self.is_saved = True def get_undeclared_template_variables( - self, jinja_env: Optional[Environment] = None, context: Optional[Dict[str, Any]] = None + self, + jinja_env: Optional[Environment] = None, + context: Optional[Dict[str, Any]] = None, ) -> Set[str]: # Create a temporary document to analyze the template without affecting the current state temp_doc = Document(self.template_file) - + # Get XML from the temporary document xml = self.xml_to_string(temp_doc._element.body) xml = self.patch_xml(xml) - + # Add headers and footers for uri in [self.HEADER_URI, self.FOOTER_URI]: for relKey, val in temp_doc._part.rels.items(): if (val.reltype == uri) and (val.target_part.blob): _xml = self.xml_to_string(parse_xml(val.target_part.blob)) xml += self.patch_xml(_xml) - + if jinja_env: env = jinja_env else: env = Environment() - + parse_content = env.parse(xml) all_variables = meta.find_undeclared_variables(parse_content) - + # If context is provided, return only variables that are not in the context if context is not None: provided_variables = set(context.keys()) return all_variables - provided_variables - + # If no context provided, return all variables (original behavior) - return all_variables \ No newline at end of file + return all_variables