From dc38194da3c2adebc595d0fdffab0f1f155de6e0 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Tue, 12 Nov 2024 19:04:39 +0000 Subject: [PATCH] ensure element is always not None --- fastkml/validator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastkml/validator.py b/fastkml/validator.py index e9b1faf7..404d625d 100644 --- a/fastkml/validator.py +++ b/fastkml/validator.py @@ -68,7 +68,7 @@ def get_schema_parser( def handle_validation_error( schema_parser: "etree.XMLSchema", - element: Optional[Element], + element: Element, ) -> None: """ Log the validation error in its XML context. @@ -82,7 +82,7 @@ def handle_validation_error( log = schema_parser.error_log for error_entry in log: try: - parent = element.xpath(error_entry.path)[ # type: ignore[union-attr] + parent = element.xpath(error_entry.path)[ # type: ignore[attr-defined] 0 ].getparent() except config.etree.XPathEvalError: @@ -137,7 +137,7 @@ def validate( if file_to_validate is not None: element = config.etree.parse(file_to_validate) - + assert element is not None # noqa: S101 try: schema_parser.assert_(element) # noqa: PT009 except AssertionError: