Skip to content

Commit 67cfbfe

Browse files
committed
Define equality for Provider objects
1 parent 3186644 commit 67cfbfe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pystac/provider.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from enum import Enum
22
from typing import Any, Dict, List, Optional
33

4+
45
class ProviderRole(str, Enum):
56
"""Enumerates the allows values of the Provider "role" field."""
67

@@ -63,6 +64,11 @@ def __init__(
6364
self.url = url
6465
self.extra_fields = extra_fields or {}
6566

67+
def __eq__(self, o: object) -> bool:
68+
if not isinstance(o, Provider):
69+
return NotImplemented
70+
return self.to_dict() == o.to_dict()
71+
6672
def to_dict(self) -> Dict[str, Any]:
6773
"""Generate a dictionary representing the JSON of this Provider.
6874
@@ -100,4 +106,4 @@ def from_dict(d: Dict[str, Any]) -> "Provider":
100106
for k, v in d.items()
101107
if k not in {"name", "description", "roles", "url"}
102108
},
103-
)
109+
)

0 commit comments

Comments
 (0)