From 8b969acc4a6a1d9ed91ed25a87fcdd53e0c9fa3f Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 6 Jul 2021 13:28:46 +1200 Subject: [PATCH] chore: Remove unused `__str__` methods They were only accessed by tests. --- pystac/catalog.py | 3 --- pystac/collection.py | 3 --- pystac/extensions/file.py | 3 --- pystac/extensions/label.py | 12 ------------ pystac/extensions/raster.py | 6 ------ pystac/extensions/scientific.py | 3 --- pystac/extensions/version.py | 3 --- pystac/media_type.py | 3 --- pystac/rel_type.py | 3 --- pystac/stac_object.py | 3 --- pystac/utils.py | 3 --- tests/extensions/test_file.py | 4 ++-- tests/extensions/test_label.py | 14 +++++++------- tests/extensions/test_version.py | 6 +++--- 14 files changed, 12 insertions(+), 57 deletions(-) diff --git a/pystac/catalog.py b/pystac/catalog.py index ea77557d1..d0a599552 100644 --- a/pystac/catalog.py +++ b/pystac/catalog.py @@ -37,9 +37,6 @@ class CatalogType(str, Enum): - def __str__(self) -> str: - return str(self.value) - SELF_CONTAINED = "SELF_CONTAINED" """A 'self-contained catalog' is one that is designed for portability. Users may want to download an online catalog from and be able to use it on their diff --git a/pystac/collection.py b/pystac/collection.py index e858d7e20..2694fa2bf 100644 --- a/pystac/collection.py +++ b/pystac/collection.py @@ -412,9 +412,6 @@ def from_items( class ProviderRole(str, Enum): """Enumerates the allows values of the Provider "role" field.""" - def __str__(self) -> str: - return str(self.value) - LICENSOR = "licensor" PRODUCER = "producer" PROCESSOR = "processor" diff --git a/pystac/extensions/file.py b/pystac/extensions/file.py index 11093c12e..c912efdc7 100644 --- a/pystac/extensions/file.py +++ b/pystac/extensions/file.py @@ -30,9 +30,6 @@ class ByteOrder(str, Enum): """List of allows values for the ``"file:byte_order"`` field defined by the :stac-ext:`File Info Extension `.""" - def __str__(self) -> str: - return str(self.value) - LITTLE_ENDIAN = "little-endian" BIG_ENDIAN = "big-endian" diff --git a/pystac/extensions/label.py b/pystac/extensions/label.py index 9398ad14f..332640fe3 100644 --- a/pystac/extensions/label.py +++ b/pystac/extensions/label.py @@ -32,9 +32,6 @@ class LabelRelType(str, Enum): documentation for details. """ - def __str__(self) -> str: - return str(self.value) - SOURCE = "source" """Used to indicate a link to the source item to which a label item applies.""" @@ -42,9 +39,6 @@ def __str__(self) -> str: class LabelType(str, Enum): """Enumerates valid label types ("raster" or "vector").""" - def __str__(self) -> str: - return str(self.value) - VECTOR = "vector" RASTER = "raster" @@ -55,9 +49,6 @@ def __str__(self) -> str: class LabelTask(str, Enum): """Enumerates recommended values for "label:tasks" field.""" - def __str__(self) -> str: - return str(self.value) - REGRESSION = "regression" CLASSIFICATION = "classification" DETECTION = "detection" @@ -67,9 +58,6 @@ def __str__(self) -> str: class LabelMethod(str, Enum): """Enumerates recommended values for "label:methods" field.""" - def __str__(self) -> str: - return str(self.value) - AUTOMATED = "automated" MANUAL = "manual" diff --git a/pystac/extensions/raster.py b/pystac/extensions/raster.py index 919923f3e..bffb627a6 100644 --- a/pystac/extensions/raster.py +++ b/pystac/extensions/raster.py @@ -20,17 +20,11 @@ class Sampling(str, enum.Enum): - def __str__(self) -> str: - return str(self.value) - AREA = "area" POINT = "point" class DataType(str, enum.Enum): - def __str__(self) -> str: - return str(self.value) - INT8 = "int8" INT16 = "int16" INT32 = "int32" diff --git a/pystac/extensions/scientific.py b/pystac/extensions/scientific.py index f27cea902..8ebc944be 100644 --- a/pystac/extensions/scientific.py +++ b/pystac/extensions/scientific.py @@ -42,9 +42,6 @@ class ScientificRelType(str, Enum): ` documentation for details. """ - def __str__(self) -> str: - return str(self.value) - CITE_AS = "cite-as" """Used to indicate a link to the publication referenced by the ``sci:doi`` field.""" diff --git a/pystac/extensions/version.py b/pystac/extensions/version.py index 00dc671d1..cbc47e630 100644 --- a/pystac/extensions/version.py +++ b/pystac/extensions/version.py @@ -30,9 +30,6 @@ class VersionRelType(str, Enum): `__ documentation for details.""" - def __str__(self) -> str: - return str(self.value) - LATEST = "latest-version" """Indicates a link pointing to a resource containing the latest version.""" diff --git a/pystac/media_type.py b/pystac/media_type.py index b74c5f51d..d172c4511 100644 --- a/pystac/media_type.py +++ b/pystac/media_type.py @@ -4,9 +4,6 @@ class MediaType(str, Enum): """A list of common media types that can be used in STAC Asset and Link metadata.""" - def __str__(self) -> str: - return str(self.value) - COG = "image/tiff; application=geotiff; profile=cloud-optimized" GEOJSON = "application/geo+json" GEOPACKAGE = "application/geopackage+sqlite3" diff --git a/pystac/rel_type.py b/pystac/rel_type.py index 87db25d04..234a45ead 100644 --- a/pystac/rel_type.py +++ b/pystac/rel_type.py @@ -12,9 +12,6 @@ class RelType(str, Enum): specific to those STAC objects. """ - def __str__(self) -> str: - return str(self.value) - ALTERNATE = "alternate" CANONICAL = "canonical" CHILD = "child" diff --git a/pystac/stac_object.py b/pystac/stac_object.py index a2729c0e8..89cf817ed 100644 --- a/pystac/stac_object.py +++ b/pystac/stac_object.py @@ -12,9 +12,6 @@ class STACObjectType(str, Enum): - def __str__(self) -> str: - return str(self.value) - CATALOG = "Catalog" COLLECTION = "Collection" ITEM = "Feature" diff --git a/pystac/utils.py b/pystac/utils.py index c3b09f2d0..50cdbb1be 100644 --- a/pystac/utils.py +++ b/pystac/utils.py @@ -40,9 +40,6 @@ def safe_urlparse(href: str) -> URLParseResult: class JoinType(str, Enum): """Allowed join types for the :func:`_join` function.""" - def __str__(self) -> str: - return str(self.value) - @staticmethod def from_parsed_uri(parsed_uri: URLParseResult) -> "JoinType": """Determines the appropriate join type based on the scheme of the parsed diff --git a/tests/extensions/test_file.py b/tests/extensions/test_file.py index e73f83806..d470031e5 100644 --- a/tests/extensions/test_file.py +++ b/tests/extensions/test_file.py @@ -9,8 +9,8 @@ class ByteOrderTest(unittest.TestCase): def test_to_str(self) -> None: - self.assertEqual(str(ByteOrder.LITTLE_ENDIAN), "little-endian") - self.assertEqual(str(ByteOrder.BIG_ENDIAN), "big-endian") + self.assertEqual(ByteOrder.LITTLE_ENDIAN.value, "little-endian") + self.assertEqual(ByteOrder.BIG_ENDIAN.value, "big-endian") class MappingObjectTest(unittest.TestCase): diff --git a/tests/extensions/test_label.py b/tests/extensions/test_label.py index e7d20cdbe..aa399a9e7 100644 --- a/tests/extensions/test_label.py +++ b/tests/extensions/test_label.py @@ -24,21 +24,21 @@ class LabelTypeTest(unittest.TestCase): def test_to_str(self) -> None: - self.assertEqual(str(LabelType.VECTOR), "vector") - self.assertEqual(str(LabelType.RASTER), "raster") + self.assertEqual(LabelType.VECTOR.value, "vector") + self.assertEqual(LabelType.RASTER.value, "raster") class LabelRelTypeTest(unittest.TestCase): def test_rel_types(self) -> None: - self.assertEqual(str(LabelRelType.SOURCE), "source") + self.assertEqual(LabelRelType.SOURCE.value, "source") class LabelTaskTest(unittest.TestCase): def test_rel_types(self) -> None: - self.assertEqual(str(LabelTask.REGRESSION), "regression") - self.assertEqual(str(LabelTask.CLASSIFICATION), "classification") - self.assertEqual(str(LabelTask.DETECTION), "detection") - self.assertEqual(str(LabelTask.SEGMENTATION), "segmentation") + self.assertEqual(LabelTask.REGRESSION.value, "regression") + self.assertEqual(LabelTask.CLASSIFICATION.value, "classification") + self.assertEqual(LabelTask.DETECTION.value, "detection") + self.assertEqual(LabelTask.SEGMENTATION.value, "segmentation") class LabelCountTest(unittest.TestCase): diff --git a/tests/extensions/test_version.py b/tests/extensions/test_version.py index 73356cc89..f73229f61 100644 --- a/tests/extensions/test_version.py +++ b/tests/extensions/test_version.py @@ -49,9 +49,9 @@ def setUp(self) -> None: self.example_item_uri = TestCases.get_path("data-files/version/item.json") def test_rel_types(self) -> None: - self.assertEqual(str(VersionRelType.LATEST), "latest-version") - self.assertEqual(str(VersionRelType.PREDECESSOR), "predecessor-version") - self.assertEqual(str(VersionRelType.SUCCESSOR), "successor-version") + self.assertEqual(VersionRelType.LATEST.value, "latest-version") + self.assertEqual(VersionRelType.PREDECESSOR.value, "predecessor-version") + self.assertEqual(VersionRelType.SUCCESSOR.value, "successor-version") def test_stac_extensions(self) -> None: self.assertTrue(VersionExtension.has_extension(self.item))