From 67fa32b8f22810dda752225d1903a5c2ea28820d Mon Sep 17 00:00:00 2001 From: CodyInnowhere Date: Mon, 2 Dec 2024 16:02:38 +0800 Subject: [PATCH] fix type check in handle_image --- trafilatura/main_extractor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trafilatura/main_extractor.py b/trafilatura/main_extractor.py index 6431896c..5b6ad070 100644 --- a/trafilatura/main_extractor.py +++ b/trafilatura/main_extractor.py @@ -440,8 +440,11 @@ def handle_table(table_elem: _Element, potential_tags: Set[str], options: Extrac return None -def handle_image(element: _Element) -> Optional[_Element]: +def handle_image(element: Optional[_Element]) -> Optional[_Element]: "Process image elements and their relevant attributes." + if element is None: + return None + processed_element = Element(element.tag) for attr in ("data-src", "src"):