Skip to content

Commit af71e74

Browse files
authored
Merge pull request #375 from schwehr/optional
cache.py, layout.py: Add missing Optional type annotations
2 parents 86c1c6d + a2b704d commit af71e74

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

pystac/cache.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(
6363
self,
6464
id_keys_to_objects: Optional[Dict[str, "STACObject_Type"]] = None,
6565
hrefs_to_objects: Optional[Dict[str, "STACObject_Type"]] = None,
66-
ids_to_collections: Dict[str, "Collection_Type"] = None,
66+
ids_to_collections: Optional[Dict[str, "Collection_Type"]] = None,
6767
):
6868
self.id_keys_to_objects = id_keys_to_objects or {}
6969
self.hrefs_to_objects = hrefs_to_objects or {}
@@ -235,8 +235,12 @@ class CollectionCache:
235235

236236
def __init__(
237237
self,
238-
cached_ids: Dict[str, Union["Collection_Type", Dict[str, Any]]] = None,
239-
cached_hrefs: Dict[str, Union["Collection_Type", Dict[str, Any]]] = None,
238+
cached_ids: Optional[
239+
Dict[str, Union["Collection_Type", Dict[str, Any]]]
240+
] = None,
241+
cached_hrefs: Optional[
242+
Dict[str, Union["Collection_Type", Dict[str, Any]]]
243+
] = None,
240244
):
241245
self.cached_ids = cached_ids or {}
242246
self.cached_hrefs = cached_hrefs or {}
@@ -273,8 +277,12 @@ class ResolvedObjectCollectionCache(CollectionCache):
273277
def __init__(
274278
self,
275279
resolved_object_cache: ResolvedObjectCache,
276-
cached_ids: Dict[str, Union["Collection_Type", Dict[str, Any]]] = None,
277-
cached_hrefs: Dict[str, Union["Collection_Type", Dict[str, Any]]] = None,
280+
cached_ids: Optional[
281+
Dict[str, Union["Collection_Type", Dict[str, Any]]]
282+
] = None,
283+
cached_hrefs: Optional[
284+
Dict[str, Union["Collection_Type", Dict[str, Any]]]
285+
] = None,
278286
):
279287
super().__init__(cached_ids, cached_hrefs)
280288
self.resolved_object_cache = resolved_object_cache

pystac/layout.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ class LayoutTemplate:
7474
# Special template vars specific to Items
7575
ITEM_TEMPLATE_VARS = ["date", "year", "month", "day", "collection"]
7676

77-
def __init__(self, template: str, defaults: Dict[str, str] = None) -> None:
77+
def __init__(
78+
self, template: str, defaults: Optional[Dict[str, str]] = None
79+
) -> None:
7880
self.template = template
7981
self.defaults = defaults or {}
8082

0 commit comments

Comments
 (0)