Skip to content

Commit

Permalink
Ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Dec 12, 2023
1 parent 8c8d92d commit 62e1d80
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 4 additions & 3 deletions fastkml/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,10 @@ def _get_kwargs(
kwargs["description"] = description.text
visibility = element.find(f"{ns}visibility")
if visibility is not None and visibility.text:
kwargs["visibility"] = visibility.text in ["1", "true"]
kwargs["visibility"] = visibility.text in {"1", "true"}
isopen = element.find(f"{ns}open")
if isopen is not None:
kwargs["isopen"] = isopen.text in ["1", "true"]
kwargs["isopen"] = isopen.text in {"1", "true"}
address = element.find(f"{ns}address")
if address is not None:
kwargs["address"] = address.text
Expand Down Expand Up @@ -541,7 +541,8 @@ def __init__(
extended_data=extended_data,
)
if kml_geometry and geometry:
raise ValueError("You can only specify one of kml_geometry or geometry")
msg = "You can only specify one of kml_geometry or geometry"
raise ValueError(msg)
if geometry:
kml_geometry = create_kml_geometry( # type: ignore[assignment]
geometry=geometry,
Expand Down
3 changes: 2 additions & 1 deletion fastkml/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,5 @@ def create_kml_geometry(
geometry=geom,
),
)
raise KMLWriteError(f"Unsupported geometry type {type(geometry)}")
msg = f"Unsupported geometry type {type(geometry)}"
raise KMLWriteError(msg)
2 changes: 1 addition & 1 deletion fastkml/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def _get_kwargs(
key = pair.find(f"{ns}key")
style = pair.find(f"{ns}Style")
style_url = pair.find(f"{ns}styleUrl")
if key is None or key.text not in ["highlight", "normal"]:
if key is None or key.text not in {"highlight", "normal"}:
raise ValueError
elif key.text == "highlight":
if style is not None:
Expand Down
8 changes: 4 additions & 4 deletions fastkml/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ def etree_element(
)
tilt.text = str(self.tilt)
if self.altitude_mode:
if self.altitude_mode in (
if self.altitude_mode in {
AltitudeMode.clamp_to_ground,
AltitudeMode.relative_to_ground,
AltitudeMode.absolute,
):
}:
altitude_mode = config.etree.SubElement( # type: ignore[attr-defined]
element,
f"{self.ns}altitudeMode",
)
elif self.altitude_mode in (
elif self.altitude_mode in {
AltitudeMode.clamp_to_sea_floor,
AltitudeMode.relative_to_sea_floor,
):
}:
altitude_mode = config.etree.SubElement( # type: ignore[attr-defined]
element,
f"{self.name_spaces['gx']}altitudeMode",
Expand Down

0 comments on commit 62e1d80

Please sign in to comment.