Skip to content

Commit a3bffe2

Browse files
committed
feat: Raise not implemented error in abstract methods
Better to signal an issue rather than doing nothing.
1 parent cf39b3f commit a3bffe2

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

pystac/extensions/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ExtensionManagementMixin(Generic[S], ABC):
9595
@abstractmethod
9696
def get_schema_uri(cls) -> str:
9797
"""Gets the schema URI associated with this extension."""
98-
pass
98+
raise NotImplementedError
9999

100100
@classmethod
101101
def add_to(cls, obj: S) -> None:

pystac/extensions/hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ExtensionHooks(ABC):
1414
@abstractmethod
1515
def schema_uri(self) -> str:
1616
"""The schema_uri for the current version of this extension"""
17-
pass
17+
raise NotImplementedError
1818

1919
@property
2020
@abstractmethod
@@ -24,13 +24,13 @@ def prev_extension_ids(self) -> Set[str]:
2424
property. Override with a class attribute so that the set of previous
2525
IDs is only created once.
2626
"""
27-
pass
27+
raise NotImplementedError
2828

2929
@property
3030
@abstractmethod
3131
def stac_object_types(self) -> Set[pystac.STACObjectType]:
3232
"""A set of STACObjectType for which migration logic will be applied."""
33-
pass
33+
raise NotImplementedError
3434

3535
@lru_cache()
3636
def _get_stac_object_types(self) -> Set[str]:

pystac/layout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,17 @@ def get_href(
249249
def get_catalog_href(
250250
self, cat: "Catalog_Type", parent_dir: str, is_root: bool
251251
) -> str:
252-
pass
252+
raise NotImplementedError
253253

254254
@abstractmethod
255255
def get_collection_href(
256256
self, col: "Collection_Type", parent_dir: str, is_root: bool
257257
) -> str:
258-
pass
258+
raise NotImplementedError
259259

260260
@abstractmethod
261261
def get_item_href(self, item: "Item_Type", parent_dir: str) -> str:
262-
pass
262+
raise NotImplementedError
263263

264264

265265
class CustomLayoutStrategy(HrefLayoutStrategy):

pystac/stac_object.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def _object_links(self) -> List[str]:
420420
STACObjects linked to by this object (not including root, parent or self).
421421
This can include optional relations (which may not be present).
422422
"""
423-
pass
423+
raise NotImplementedError
424424

425425
@abstractmethod
426426
def to_dict(self, include_self_link: bool = True) -> Dict[str, Any]:
@@ -432,7 +432,7 @@ def to_dict(self, include_self_link: bool = True) -> Dict[str, Any]:
432432
433433
dict: A serialization of the object that can be written out as JSON.
434434
"""
435-
pass
435+
raise NotImplementedError
436436

437437
@abstractmethod
438438
def clone(self) -> "STACObject":
@@ -446,7 +446,7 @@ def clone(self) -> "STACObject":
446446
Returns:
447447
STACObject: The clone of this object.
448448
"""
449-
pass
449+
raise NotImplementedError
450450

451451
@classmethod
452452
def from_file(
@@ -517,7 +517,7 @@ def from_dict(
517517
Returns:
518518
STACObject: The STACObject parsed from this dict.
519519
"""
520-
pass
520+
raise NotImplementedError
521521

522522
@classmethod
523523
@abstractmethod

pystac/validation/schema_uri_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_object_schema_uri(
2828
Returns:
2929
str: The URI of the schema, or None if not found.
3030
"""
31-
pass
31+
raise NotImplementedError
3232

3333

3434
class DefaultSchemaUriMap(SchemaUriMap):

pystac/validation/stac_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def validate_core(
4444
stac_version : The version of STAC to validate the object against.
4545
href : Optional HREF of the STAC object being validated.
4646
"""
47-
pass
47+
raise NotImplementedError
4848

4949
@abstractmethod
5050
def validate_extension(
@@ -67,7 +67,7 @@ def validate_extension(
6767
extension_id : The extension ID of the extension to validate against.
6868
href : Optional HREF of the STAC object being validated.
6969
"""
70-
pass
70+
raise NotImplementedError
7171

7272
def validate(
7373
self,

0 commit comments

Comments
 (0)