Skip to content

Commit 1a7f66b

Browse files
author
Jon Duckworth
authored
Merge pull request #530 from l0b0/refactor/do-not-change-import-name-if-unnecessary
refactor: Don't change name of import if unnecessary
2 parents c84d398 + c04df2f commit 1a7f66b

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

pystac/collection.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from copy import deepcopy
2-
from datetime import datetime as Datetime
2+
from datetime import datetime
33
from enum import Enum
44
from pystac.errors import STACTypeError
55
from typing import (
@@ -175,7 +175,7 @@ class TemporalExtent:
175175
Datetimes are required to be in UTC.
176176
"""
177177

178-
intervals: List[List[Optional[Datetime]]]
178+
intervals: List[List[Optional[datetime]]]
179179
"""A list of two datetimes wrapped in a list,
180180
representing the temporal extent of a Collection. Open date ranges are
181181
represented by either the start (the first element of the interval) or the
@@ -187,16 +187,16 @@ class TemporalExtent:
187187

188188
def __init__(
189189
self,
190-
intervals: Union[List[List[Optional[Datetime]]], List[Optional[Datetime]]],
190+
intervals: Union[List[List[Optional[datetime]]], List[Optional[datetime]]],
191191
extra_fields: Optional[Dict[str, Any]] = None,
192192
):
193193
# A common mistake is to pass in a single interval instead of a
194194
# list of intervals. Account for this by transforming the input
195195
# in that case.
196-
if isinstance(intervals, list) and isinstance(intervals[0], Datetime):
197-
self.intervals = [cast(List[Optional[Datetime]], intervals)]
196+
if isinstance(intervals, list) and isinstance(intervals[0], datetime):
197+
self.intervals = [cast(List[Optional[datetime]], intervals)]
198198
else:
199-
self.intervals = cast(List[List[Optional[Datetime]]], intervals)
199+
self.intervals = cast(List[List[Optional[datetime]]], intervals)
200200

201201
self.extra_fields = extra_fields or {}
202202

@@ -239,7 +239,7 @@ def from_dict(d: Dict[str, Any]) -> "TemporalExtent":
239239
Returns:
240240
TemporalExtent: The TemporalExtent deserialized from the JSON dict.
241241
"""
242-
parsed_intervals: List[List[Optional[Datetime]]] = []
242+
parsed_intervals: List[List[Optional[datetime]]] = []
243243
for i in d["interval"]:
244244
start = None
245245
end = None
@@ -264,7 +264,7 @@ def from_now() -> "TemporalExtent":
264264
TemporalExtent: The resulting TemporalExtent.
265265
"""
266266
return TemporalExtent(
267-
intervals=[[Datetime.utcnow().replace(microsecond=0), None]]
267+
intervals=[[datetime.utcnow().replace(microsecond=0), None]]
268268
)
269269

270270

@@ -360,9 +360,9 @@ def from_items(
360360
[float("-inf")],
361361
[float("-inf")],
362362
]
363-
datetimes: List[Datetime] = []
364-
starts: List[Datetime] = []
365-
ends: List[Datetime] = []
363+
datetimes: List[datetime] = []
364+
starts: List[datetime] = []
365+
ends: List[datetime] = []
366366

367367
for item in items:
368368
if item.bbox is not None:

pystac/extensions/timestamps.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://github.com/stac-extensions/timestamps
44
"""
55

6-
from datetime import datetime as Datetime
6+
from datetime import datetime as datetime
77
from pystac.summaries import RangeSummary
88
from typing import Dict, Any, Iterable, Generic, Optional, TypeVar, cast
99

@@ -44,9 +44,9 @@ class TimestampsExtension(
4444

4545
def apply(
4646
self,
47-
published: Optional[Datetime] = None,
48-
expires: Optional[Datetime] = None,
49-
unpublished: Optional[Datetime] = None,
47+
published: Optional[datetime] = None,
48+
expires: Optional[datetime] = None,
49+
unpublished: Optional[datetime] = None,
5050
) -> None:
5151
"""Applies timestamps extension properties to the extended Item.
5252
@@ -63,7 +63,7 @@ def apply(
6363
self.unpublished = unpublished
6464

6565
@property
66-
def published(self) -> Optional[Datetime]:
66+
def published(self) -> Optional[datetime]:
6767
"""Gets or sets a datetime object that represents the date and time that the
6868
corresponding data was published the first time.
6969
@@ -75,11 +75,11 @@ def published(self) -> Optional[Datetime]:
7575
return map_opt(str_to_datetime, self._get_property(PUBLISHED_PROP, str))
7676

7777
@published.setter
78-
def published(self, v: Optional[Datetime]) -> None:
78+
def published(self, v: Optional[datetime]) -> None:
7979
self._set_property(PUBLISHED_PROP, map_opt(datetime_to_str, v))
8080

8181
@property
82-
def expires(self) -> Optional[Datetime]:
82+
def expires(self) -> Optional[datetime]:
8383
"""Gets or sets a datetime object that represents the date and time the
8484
corresponding data expires (is not valid any longer).
8585
@@ -91,11 +91,11 @@ def expires(self) -> Optional[Datetime]:
9191
return map_opt(str_to_datetime, self._get_property(EXPIRES_PROP, str))
9292

9393
@expires.setter
94-
def expires(self, v: Optional[Datetime]) -> None:
94+
def expires(self, v: Optional[datetime]) -> None:
9595
self._set_property(EXPIRES_PROP, map_opt(datetime_to_str, v))
9696

9797
@property
98-
def unpublished(self) -> Optional[Datetime]:
98+
def unpublished(self) -> Optional[datetime]:
9999
"""Gets or sets a datetime object that represents the date and time the
100100
corresponding data was unpublished.
101101
@@ -107,7 +107,7 @@ def unpublished(self) -> Optional[Datetime]:
107107
return map_opt(str_to_datetime, self._get_property(UNPUBLISHED_PROP, str))
108108

109109
@unpublished.setter
110-
def unpublished(self, v: Optional[Datetime]) -> None:
110+
def unpublished(self, v: Optional[datetime]) -> None:
111111
self._set_property(UNPUBLISHED_PROP, map_opt(datetime_to_str, v))
112112

113113
@classmethod
@@ -206,7 +206,7 @@ class SummariesTimestampsExtension(SummariesExtension):
206206
"""
207207

208208
@property
209-
def published(self) -> Optional[RangeSummary[Datetime]]:
209+
def published(self) -> Optional[RangeSummary[datetime]]:
210210
"""Get or sets the summary of :attr:`TimestampsExtension.published` values
211211
for this Collection.
212212
"""
@@ -219,7 +219,7 @@ def published(self) -> Optional[RangeSummary[Datetime]]:
219219
)
220220

221221
@published.setter
222-
def published(self, v: Optional[RangeSummary[Datetime]]) -> None:
222+
def published(self, v: Optional[RangeSummary[datetime]]) -> None:
223223
self._set_summary(
224224
PUBLISHED_PROP,
225225
map_opt(
@@ -231,7 +231,7 @@ def published(self, v: Optional[RangeSummary[Datetime]]) -> None:
231231
)
232232

233233
@property
234-
def expires(self) -> Optional[RangeSummary[Datetime]]:
234+
def expires(self) -> Optional[RangeSummary[datetime]]:
235235
"""Get or sets the summary of :attr:`TimestampsExtension.expires` values
236236
for this Collection.
237237
"""
@@ -244,7 +244,7 @@ def expires(self) -> Optional[RangeSummary[Datetime]]:
244244
)
245245

246246
@expires.setter
247-
def expires(self, v: Optional[RangeSummary[Datetime]]) -> None:
247+
def expires(self, v: Optional[RangeSummary[datetime]]) -> None:
248248
self._set_summary(
249249
EXPIRES_PROP,
250250
map_opt(
@@ -256,7 +256,7 @@ def expires(self, v: Optional[RangeSummary[Datetime]]) -> None:
256256
)
257257

258258
@property
259-
def unpublished(self) -> Optional[RangeSummary[Datetime]]:
259+
def unpublished(self) -> Optional[RangeSummary[datetime]]:
260260
"""Get or sets the summary of :attr:`TimestampsExtension.unpublished` values
261261
for this Collection.
262262
"""
@@ -269,7 +269,7 @@ def unpublished(self) -> Optional[RangeSummary[Datetime]]:
269269
)
270270

271271
@unpublished.setter
272-
def unpublished(self, v: Optional[RangeSummary[Datetime]]) -> None:
272+
def unpublished(self, v: Optional[RangeSummary[datetime]]) -> None:
273273
self._set_summary(
274274
UNPUBLISHED_PROP,
275275
map_opt(

0 commit comments

Comments
 (0)