File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 18
18
- Expand support for previous extension schema URIs ([ #1091 ] ( https://github.com/stac-utils/pystac/pull/1091 ) )
19
19
- Use ` pyproject.toml ` instead of ` setup.py ` ([ #1100 ] ( https://github.com/stac-utils/pystac/pull/1100 ) )
20
20
- ` DefaultStacIO ` now raises an error if it tries to write to a non-local url ([ #1107 ] ( https://github.com/stac-utils/pystac/pull/1107 ) )
21
+ - Allow instantiation of pystac objects even with ` "stac_extensions": null ` ([ #1109 ] ( https://github.com/stac-utils/pystac/pull/1109 ) )
21
22
22
23
### Deprecated
23
24
Original file line number Diff line number Diff line change @@ -184,15 +184,10 @@ def migrate_to_latest(
184
184
185
185
if version != STACVersion .DEFAULT_STAC_VERSION :
186
186
object_migrations [info .object_type ](result , version , info )
187
- if "stac_extensions" not in result :
188
- # Force stac_extensions property, as it makes
189
- # downstream migration less complex
190
- result ["stac_extensions" ] = []
191
187
result ["stac_version" ] = STACVersion .DEFAULT_STAC_VERSION
192
- else :
193
- # Ensure stac_extensions property for consistency
194
- if "stac_extensions" not in result :
195
- result ["stac_extensions" ] = []
188
+
189
+ # Ensure stac_extensions property for consistency
190
+ result ["stac_extensions" ] = result .get ("stac_extensions" , None ) or []
196
191
197
192
pystac .EXTENSION_HOOKS .migrate (result , version , info )
198
193
for ext in result ["stac_extensions" ][:]:
Original file line number Diff line number Diff line change @@ -99,3 +99,13 @@ def test_should_raise_exception_when_passing_invalid_extension_object(
99
99
match = r"^Item Assets extension does not apply to type 'object'$" ,
100
100
):
101
101
ItemAssetsExtension .ext (object ()) # type: ignore
102
+
103
+
104
+ def test_migrate_works_even_if_stac_extensions_is_null (
105
+ test_case_1_catalog : pystac .Catalog ,
106
+ ) -> None :
107
+ collection = list (test_case_1_catalog .get_all_collections ())[0 ]
108
+ collection_dict = collection .to_dict ()
109
+ collection_dict ["stac_extensions" ] = None
110
+
111
+ pystac .Collection .from_dict (collection_dict , migrate = True )
You can’t perform that action at this time.
0 commit comments