Skip to content

Commit

Permalink
Revert "Apply StacIO instance from root in Catalog.set_root (#590)" (#…
Browse files Browse the repository at this point in the history
…633)

This reverts commit 5ddfa83.
  • Loading branch information
Jon Duckworth authored Oct 28, 2021
1 parent 4cc8483 commit 60c755e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
- Enable [strict
mode](https://mypy.readthedocs.io/en/latest/command_line.html?highlight=strict%20mode#cmdoption-mypy-strict)
for `mypy` ([#591](https://github.com/stac-utils/pystac/pull/591))
- `Catalog.set_root` also sets `Catalog.stac_io` for the calling instance to be the same
as `root.stac_io`, if that value is not `None`
([#590](https://github.com/stac-utils/pystac/pull/590))
- Links will get their `title` from their target if no `title` is provided ([#607](https://github.com/stac-utils/pystac/pull/607))
- Relax typing on `LabelClasses` from `List` to `Sequence` ([#627](https://github.com/stac-utils/pystac/pull/627))

Expand Down
10 changes: 4 additions & 6 deletions pystac/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CatalogType(str, Enum):
See:
:stac-spec:`The best practices documentation on self-contained catalogs
<best-practices.md#self-contained-catalogs>`
<best-practices.md#self-contained-catalogs>`
"""

ABSOLUTE_PUBLISHED = "ABSOLUTE_PUBLISHED"
Expand All @@ -55,7 +55,7 @@ class CatalogType(str, Enum):
See:
:stac-spec:`The best practices documentation on published catalogs
<best-practices.md#published-catalogs>`
<best-practices.md#published-catalogs>`
"""

RELATIVE_PUBLISHED = "RELATIVE_PUBLISHED"
Expand All @@ -65,7 +65,7 @@ class CatalogType(str, Enum):
See:
:stac-spec:`The best practices documentation on published catalogs
<best-practices.md#published-catalogs>`
<best-practices.md#published-catalogs>`
"""

@classmethod
Expand Down Expand Up @@ -181,13 +181,11 @@ def __repr__(self) -> str:
return "<Catalog id={}>".format(self.id)

def set_root(self, root: Optional["Catalog"]) -> None:
super().set_root(root)
STACObject.set_root(self, root)
if root is not None:
root._resolved_objects = ResolvedObjectCache.merge(
root._resolved_objects, self._resolved_objects
)
if root._stac_io is not None:
self._stac_io = root._stac_io

def is_relative(self) -> bool:
return self.catalog_type in [
Expand Down
14 changes: 0 additions & 14 deletions tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
HIERARCHICAL_LINKS,
)
from pystac.extensions.label import LabelClasses, LabelExtension, LabelType
from pystac.stac_io import DefaultStacIO
from pystac.utils import is_absolute_href, join_path_or_url, JoinType
from tests.utils import (
TestCases,
Expand Down Expand Up @@ -108,19 +107,6 @@ def test_from_dict_set_root(self) -> None:
collection = Catalog.from_dict(cat_dict, root=root_cat)
self.assertIs(collection.get_root(), root_cat)

def test_from_dict_uses_root_stac_io(self) -> None:
class CustomStacIO(DefaultStacIO):
pass

path = TestCases.get_path("data-files/catalogs/test-case-1/catalog.json")
with open(path) as f:
cat_dict = json.load(f)
root_cat = pystac.Catalog(id="test", description="test desc")
root_cat._stac_io = CustomStacIO()

collection = Catalog.from_dict(cat_dict, root=root_cat)
self.assertIsInstance(collection._stac_io, CustomStacIO)

def test_read_remote(self) -> None:
# TODO: Move this URL to the main stac-spec repo once the example JSON is fixed.
catalog_url = (
Expand Down

0 comments on commit 60c755e

Please sign in to comment.