rf: use assertion in place of try/except to tell Mypy that something is

This is the way that this should have been done all along.

See: https://github.com/python/mypy/issues/5528 for a reference (though 
not the source) of this concept
This commit is contained in:
Benjamin Kirkbride
2020-04-19 04:22:34 -04:00
parent a0dc12e68e
commit 7580339415

View File

@@ -245,10 +245,8 @@ def _parse_tile_layer(element: etree.Element,) -> objects.TileLayer:
size = objects.Size(width, height)
data_element = element.find("./data")
if data_element is not None:
data: objects.LayerData = _parse_data(data_element, width)
else:
raise ValueError(f"{element} has no child data element.")
assert data_element is not None
data: objects.LayerData = _parse_data(data_element, width)
return objects.TileLayer(
id_=id_,