Skip to content

Commit

Permalink
Merge pull request #514 from l0b0/refactor/remove-str-methods
Browse files Browse the repository at this point in the history
chore: Remove unused `__str__` methods
  • Loading branch information
Jon Duckworth authored Jul 8, 2021
2 parents 726be1e + 8b969ac commit aa76c8d
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 57 deletions.
3 changes: 0 additions & 3 deletions pystac/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions pystac/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions pystac/extensions/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file>`."""

def __str__(self) -> str:
return str(self.value)

LITTLE_ENDIAN = "little-endian"
BIG_ENDIAN = "big-endian"

Expand Down
12 changes: 0 additions & 12 deletions pystac/extensions/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,13 @@ 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."""


class LabelType(str, Enum):
"""Enumerates valid label types ("raster" or "vector")."""

def __str__(self) -> str:
return str(self.value)

VECTOR = "vector"
RASTER = "raster"

Expand All @@ -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"
Expand All @@ -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"

Expand Down
6 changes: 0 additions & 6 deletions pystac/extensions/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions pystac/extensions/scientific.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class ScientificRelType(str, Enum):
<scientific#relation-types>` 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."""
Expand Down
3 changes: 0 additions & 3 deletions pystac/extensions/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ class VersionRelType(str, Enum):
<https://github.com/stac-extensions/version#relation-types>`__ 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."""

Expand Down
3 changes: 0 additions & 3 deletions pystac/media_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions pystac/rel_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions pystac/stac_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@


class STACObjectType(str, Enum):
def __str__(self) -> str:
return str(self.value)

CATALOG = "Catalog"
COLLECTION = "Collection"
ITEM = "Feature"
Expand Down
3 changes: 0 additions & 3 deletions pystac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/extensions/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 7 additions & 7 deletions tests/extensions/test_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/extensions/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit aa76c8d

Please sign in to comment.