Skip to content

Commit fcfad5d

Browse files
committed
Restore prior function interface
Use a different type narrowing approach
1 parent 18d651a commit fcfad5d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

antarctica_today/compute_mean_climatology.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,23 +345,26 @@ def create_baseline_climatology_tif(
345345

346346

347347
def create_partial_year_melt_anomaly_tif(
348-
current_datetime_in: Optional[datetime.datetime] = None,
348+
current_datetime: Optional[datetime.datetime] = None,
349349
dest_fname: Optional[str] = None,
350350
gap_filled: bool = True,
351351
verbose: bool = True,
352352
) -> numpy.ndarray:
353353
"""Create a tif of melt anomaly compared to baseline climatology for that day of the melt season."""
354354
# If no datetime is given, use "today"
355-
current_datetime: datetime.datetime
356-
if current_datetime_in is None:
355+
if current_datetime is None:
357356
now = datetime.datetime.today()
358357
# Strip off the hour,min,second
359358
# TODO: Why not use a datetime.date object instead?
360359
current_datetime = datetime.datetime(
361360
year=now.year, month=now.month, day=now.day
362361
)
363-
else:
364-
current_datetime = current_datetime_in
362+
363+
if not isinstance(current_datetime, datetime.datetime):
364+
raise ValueError(
365+
f"Unexpected value for current_datetime: {current_datetime}."
366+
"This should never happen, but this helps the typechecker narrow."
367+
)
365368

366369
daily_melt_sums, daily_sums_dt_dict = read_daily_sum_melt_averages_picklefile()
367370

0 commit comments

Comments
 (0)