Skip to content

Commit 41557be

Browse files
committed
Remove schema uri from stac_extensions on migrate
1 parent 045c1a6 commit 41557be

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

pystac/extensions/item_assets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,11 @@ def migrate(
9898

9999
super().migrate(obj, version, info)
100100

101+
# As of STAC spec version 1.1.0 item-assets are part of core
102+
if obj["stac_version"] >= "1.1.0" and self.schema_uri in obj.get(
103+
"stac_extensions", []
104+
):
105+
obj["stac_extensions"].remove(self.schema_uri)
106+
101107

102108
ITEM_ASSETS_EXTENSION_HOOKS: ExtensionHooks = ItemAssetsExtensionHooks()

tests/serialization/test_migrate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ def test_migrates_renamed_extension(self) -> None:
7575
)
7676
)
7777

78-
assert ItemAssetsExtension.has_extension(collection)
78+
assert ItemAssetsExtension.get_schema_uri() not in collection.stac_extensions
79+
assert not ItemAssetsExtension.has_extension(collection)
7980
assert "item_assets" in collection.extra_fields
81+
assert collection.item_assets
82+
assert collection.item_assets["thumbnail"].title == "Thumbnail"
8083

8184
def test_migrates_pre_1_0_0_rc1_stats_summary(self) -> None:
8285
collection = pystac.Collection.from_file(

tests/test_item_assets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def test_extra_fields(collection: Collection) -> None:
127127

128128
def test_item_assets_extension_is_deprecated() -> None:
129129
collection = Collection.from_file(CLASSIFICATION_COLLECTION_RASTER_URI)
130+
131+
assert ItemAssetsExtension.get_schema_uri() not in collection.stac_extensions
132+
130133
with pytest.warns(DeprecatedWarning, match="top-level collection properties"):
131134
item_asset = ItemAssetsExtension.ext(
132135
collection, add_if_missing=True

0 commit comments

Comments
 (0)