Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Oct 14, 2023
1 parent 9c01d63 commit b152467
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions fastkml/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,7 @@ def strtobool(val: str) -> int:
val = val.lower()
if val == "false":
return 0
if val == "true":
return 1
return int(float(val))
return 1 if val == "true" else int(float(val))

super().from_element(element)
fill = element.find(f"{self.ns}fill")
Expand Down Expand Up @@ -628,7 +626,7 @@ def from_element(self, element: Element) -> None:
key = pair.find(f"{self.ns}key")
style = pair.find(f"{self.ns}Style")
style_url = pair.find(f"{self.ns}styleUrl")
if key is None:
if key is None or key.text not in ["highlight", "normal"]:
raise ValueError
elif key.text == "highlight":
if style is not None:
Expand All @@ -640,7 +638,7 @@ def from_element(self, element: Element) -> None:
else:
raise ValueError
self.highlight = highlight
elif key.text == "normal":
else:
if style is not None:
normal = Style(self.ns)
normal.from_element(style)
Expand All @@ -650,8 +648,6 @@ def from_element(self, element: Element) -> None:
else:
raise ValueError
self.normal = normal
else:
raise ValueError

def etree_element(
self,
Expand Down
2 changes: 1 addition & 1 deletion tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Test(base._BaseObject):

def test_base_from_element_raises(self) -> None:
be = base._BaseObject()
element = cast(types.Element, config.etree.Element(config.KMLNS + "Base")) # type: ignore[attr-defined]
element = cast(types.Element, config.etree.Element(f"{config.KMLNS}Base"))

with pytest.raises(TypeError):
be.from_element(element=element)
Expand Down

0 comments on commit b152467

Please sign in to comment.