Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.0.alpha.6 (Sourcery refactored) #248

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions fastkml/kml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,9 +1681,7 @@ def __init__(

@property
def geometry(self) -> Optional[AnyGeometryType]:
if self._geometry is not None:
return self._geometry.geometry
return None
return self._geometry.geometry if self._geometry is not None else None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Placemark.geometry refactored with the following changes:


def from_element(self, element: Element, strict=False) -> None:
super().from_element(element)
Expand Down
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))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PolyStyle.from_element refactored with the following changes:


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"]:
Comment on lines -631 to +629
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StyleMap.from_element refactored with the following changes:

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
5 changes: 1 addition & 4 deletions tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,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"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestStdLibrary.test_base_from_element_raises refactored with the following changes:

This removes the following comments ( why? ):

# type: ignore[attr-defined]


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