Skip to content

Commit

Permalink
ensure element is always not None
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Nov 12, 2024
1 parent 1d1d5cb commit dc38194
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fastkml/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit dc38194

Please sign in to comment.