From 293e81bf9d341edd1d35f3b66faf726b82ad4885 Mon Sep 17 00:00:00 2001 From: Cesar Berrospi Ramis <75900930+ceberam@users.noreply.github.com> Date: Tue, 2 Sep 2025 07:59:55 +0200 Subject: [PATCH] fix(html): access to variable not yet declared (#2171) Signed-off-by: Cesar Berrospi Ramis --- docling/backend/html_backend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docling/backend/html_backend.py b/docling/backend/html_backend.py index 2334c645..34cd0938 100644 --- a/docling/backend/html_backend.py +++ b/docling/backend/html_backend.py @@ -467,13 +467,14 @@ class HTMLDocumentBackend(DeclarativeDocumentBackend): @contextmanager def _use_hyperlink(self, tag: Tag): + old_hyperlink: Union[AnyUrl, Path, None] = None + new_hyperlink: Union[AnyUrl, Path, None] = None this_href = tag.get("href") if this_href is None: yield None else: if isinstance(this_href, str) and this_href: - old_hyperlink: Union[AnyUrl, Path, None] = self.hyperlink - new_hyperlink: Union[AnyUrl, Path, None] = None + old_hyperlink = self.hyperlink if self.original_url is not None: this_href = urljoin(str(self.original_url), str(this_href)) # ugly fix for relative links since pydantic does not support them.