Skip to content

Commit 778725d

Browse files
Update and clarify description, license, datetime properties (#1445)
* fix docstrings for license #1377 * clarify datetime range is inclusive #1382 * ensure description is not empty #1381 * pass tests * test empty description * update changelog * Update pystac/collection.py * Update pystac/common_metadata.py --------- Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
1 parent 1be0027 commit 778725d

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- Add example of custom `StacIO` for Azure Blob Storage to docs ([#1372](https://github.com/stac-utils/pystac/pull/1372))
2424
- Noted that collection links can be used in non-item objects in STAC v1.1.0 ([#1393](https://github.com/stac-utils/pystac/pull/1393))
2525
- Move test, docs, and bench requirements out of pyproject.toml ([#1407](https://github.com/stac-utils/pystac/pull/1407))
26+
- Clarify inclusive datetime ranges, update default license, and ensure description is not empty ([#1445](https://github.com/stac-utils/pystac/pull/1445))
2627

2728
### Fixed
2829

pystac/collection.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,10 @@ class Collection(Catalog, Assets):
461461
be one of the values in :class`~pystac.CatalogType`.
462462
license : Collection's license(s) as a
463463
`SPDX License identifier <https://spdx.org/licenses/>`_,
464-
`various`, or `proprietary`. If collection includes
465-
data with multiple different licenses, use `various` and add a link for
466-
each. Defaults to 'proprietary'.
464+
or `other`. If collection includes data with multiple
465+
different licenses, use `other` and add a link for
466+
each. The licenses `various` and `proprietary` are deprecated.
467+
Defaults to 'other'.
467468
keywords : Optional list of keywords describing the collection.
468469
providers : Optional list of providers of this Collection.
469470
summaries : An optional map of property summaries,
@@ -528,7 +529,7 @@ def __init__(
528529
href: str | None = None,
529530
extra_fields: dict[str, Any] | None = None,
530531
catalog_type: CatalogType | None = None,
531-
license: str = "proprietary",
532+
license: str = "other",
532533
keywords: list[str] | None = None,
533534
providers: list[Provider] | None = None,
534535
summaries: Summaries | None = None,

pystac/common_metadata.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,18 @@ def description(self) -> str | None:
8080

8181
@description.setter
8282
def description(self, v: str | None) -> None:
83+
if v == "":
84+
raise ValueError("description cannot be an empty string")
8385
self._set_field("description", v)
8486

8587
# Date and Time Range
8688
@property
8789
def start_datetime(self) -> datetime | None:
88-
"""Get or set the object's start_datetime."""
90+
"""Get or set the object's start_datetime.
91+
92+
Note:
93+
``start_datetime`` is an inclusive datetime.
94+
"""
8995
return utils.map_opt(
9096
utils.str_to_datetime, self._get_field("start_datetime", str)
9197
)
@@ -96,7 +102,11 @@ def start_datetime(self, v: datetime | None) -> None:
96102

97103
@property
98104
def end_datetime(self) -> datetime | None:
99-
"""Get or set the item's end_datetime."""
105+
"""Get or set the item's end_datetime.
106+
107+
Note:
108+
``end_datetime`` is an inclusive datetime.
109+
"""
100110
return utils.map_opt(
101111
utils.str_to_datetime, self._get_field("end_datetime", str)
102112
)
@@ -108,7 +118,15 @@ def end_datetime(self, v: datetime | None) -> None:
108118
# License
109119
@property
110120
def license(self) -> str | None:
111-
"""Get or set the current license."""
121+
"""Get or set the current license. License should be provided
122+
as a `SPDX License identifier <https://spdx.org/licenses/>`_,
123+
or `other`. If object includes data with multiple
124+
different licenses, use `other` and add a link for
125+
each.
126+
127+
Note:
128+
The licenses `various` and `proprietary` are deprecated.
129+
"""
112130
return self._get_field("license", str)
113131

114132
@license.setter

pystac/item.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ class Item(STACObject, Assets):
5151
datetime : datetime associated with this item. If None,
5252
a start_datetime and end_datetime must be supplied.
5353
properties : A dictionary of additional metadata for the item.
54-
start_datetime : Optional start datetime, part of common metadata. This value
55-
will override any `start_datetime` key in properties.
56-
end_datetime : Optional end datetime, part of common metadata. This value
57-
will override any `end_datetime` key in properties.
54+
start_datetime : Optional inclusive start datetime, part of common metadata.
55+
This value will override any `start_datetime` key in properties.
56+
end_datetime : Optional inclusive end datetime, part of common metadata.
57+
This value will override any `end_datetime` key in properties.
5858
stac_extensions : Optional list of extensions the Item implements.
5959
href : Optional HREF for this item, which be set as the item's
6060
self link's HREF.

tests/test_common_metadata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def test_common_metadata_basics(self) -> None:
176176
x.common_metadata.description = example_description
177177
self.assertEqual(x.common_metadata.description, example_description)
178178
self.assertEqual(x.properties["description"], example_description)
179+
with self.assertRaises(ValueError):
180+
x.common_metadata.description = ""
179181

180182
# License
181183
license = "PDDL-1.0"

0 commit comments

Comments
 (0)