From cac607a8e0876a01448f2bb050d559aa0d2b649f Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Mon, 16 Oct 2023 10:49:51 +0100 Subject: [PATCH] fix ruff errors, move to alpha 6 --- docs/index.rst | 2 +- setup.py | 2 +- tests/atom_test.py | 46 ++++++++++++++++++++++---------------------- tests/base_test.py | 23 +++++++++++++++------- tests/styles_test.py | 3 ++- 5 files changed, 43 insertions(+), 33 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 10c07498..45b422b6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -63,7 +63,7 @@ requirements, namely: * You can parse any KML snippet, it does not need to be a complete KML document. * It is fully tested and actively maintained. -* Geometries are handled in the `__geo_interface__` standard. +* Geometries are handled in the ``__geo_interface__`` standard. * Minimal dependencies, pure Python. * If available, lxml_ will be used to increase its speed. diff --git a/setup.py b/setup.py index 63cb1302..3022f0e6 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def run_tests(self) -> None: setup( name="fastkml", - version="1.0.alpha.5", + version="1.0.alpha.6", description="Fast KML processing in python", long_description=( open("README.rst").read() diff --git a/tests/atom_test.py b/tests/atom_test.py index 223cdfee..09e98fdd 100644 --- a/tests/atom_test.py +++ b/tests/atom_test.py @@ -26,14 +26,14 @@ class TestStdLibrary(StdLibrary): def test_atom_link_ns(self) -> None: ns = "{http://www.opengis.net/kml/2.2}" # noqa: FS003 - l = atom.Link(ns=ns) - assert l.ns == ns - assert l.to_string().startswith( + link = atom.Link(ns=ns) + assert link.ns == ns + assert link.to_string().startswith( ' None: - l = atom.Link( + link = atom.Link( href="#here", rel="alternate", type="text/html", @@ -42,7 +42,7 @@ def test_atom_link(self) -> None: length=3456, ) - serialized = l.to_string() + serialized = link.to_string() assert ' None: assert 'length="3456"' in serialized def test_atom_link_read(self) -> None: - l = atom.Link() - l.from_string( + link = atom.Link() + link.from_string( '' ) - assert l.href == "#here" - assert l.rel == "alternate" - assert l.type == "text/html" - assert l.hreflang == "en" - assert l.title == "Title" - assert l.length == 3456 + assert link.href == "#here" + assert link.rel == "alternate" + assert link.type == "text/html" + assert link.hreflang == "en" + assert link.title == "Title" + assert link.length == 3456 def test_atom_link_read_no_href(self) -> None: - l = atom.Link() - l.from_string( + link = atom.Link() + link.from_string( '' ) - assert l.href is None + assert link.href is None def test_atom_person_ns(self) -> None: ns = "{http://www.opengis.net/kml/2.2}" # noqa: FS003 @@ -133,14 +133,14 @@ def test_author_roundtrip(self) -> None: assert a.to_string() == a2.to_string() def test_link_roundtrip(self) -> None: - l = atom.Link(href="http://localhost/", rel="alternate") - l.title = "Title" - l.type = "text/html" - l.hreflang = "en" - l.length = 4096 + link = atom.Link(href="http://localhost/", rel="alternate") + link.title = "Title" + link.type = "text/html" + link.hreflang = "en" + link.length = 4096 l2 = atom.Link() - l2.from_string(l.to_string()) - assert l.to_string() == l2.to_string() + l2.from_string(link.to_string()) + assert link.to_string() == l2.to_string() class TestLxml(Lxml, TestStdLibrary): diff --git a/tests/base_test.py b/tests/base_test.py index 5158ca0d..d6362198 100644 --- a/tests/base_test.py +++ b/tests/base_test.py @@ -33,9 +33,9 @@ def test_to_string(self) -> None: obj = base._BaseObject(id="id-0", target_id="target-id-0") obj.__name__ = "test" - assert ( - obj.to_string() - == '' + assert obj.to_string() == ( + '' ) def test_to_str_empty_ns(self) -> None: @@ -51,7 +51,10 @@ def test_from_string(self) -> None: be.__name__ = "test" be.from_string( - xml_string='' + xml_string=( + '' + ) ) assert be.id == "id-0" @@ -72,7 +75,10 @@ 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(config.KMLNS + "Base"), # type: ignore[attr-defined] + ) with pytest.raises(TypeError): be.from_element(element=element) @@ -82,7 +88,7 @@ def test_base_from_string_raises(self) -> None: with pytest.raises(TypeError): be.from_string( - xml_string='' + '' ) def test_base_class_from_string(self) -> None: @@ -117,7 +123,10 @@ def test_from_string(self) -> None: be.__name__ = "test" be.from_string( - xml_string='\n' + xml_string=( + '\n' + ) ) assert be.id == "id-0" diff --git a/tests/styles_test.py b/tests/styles_test.py index 08835c5b..551b4c49 100644 --- a/tests/styles_test.py +++ b/tests/styles_test.py @@ -317,7 +317,8 @@ def test_style_read(self) -> None: style = styles.Style() style.from_string( - '' + '' '' "ff0000ff" "random"