Skip to content

Commit

Permalink
Type hint upddates
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-turner-1 committed Sep 18, 2024
1 parent f89ece1 commit aeaa970
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/access_nri_intake/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from typing import TYPE_CHECKING

import cftime

if TYPE_CHECKING:
import xarray as xr
import xarray as xr


class EmptyFileError(Exception):
Expand Down Expand Up @@ -103,7 +101,7 @@ def _todate(t):
time_format = "%Y-%m-%d, %H:%M:%S"
ts = None
te = None
frequency = "fx"
frequency : str | tuple[int | None, str] = "fx"
has_time = time_dim in ds

if has_time:
Expand Down Expand Up @@ -133,17 +131,17 @@ def _todate(t):
# TODO: This is not a very good way to get the frequency
if dt.days >= 365:
years = round(dt.days / 365)
frequency = (years, "yr") # type: ignore
frequency = (years, "yr")
elif dt.days >= 28:
months = round(dt.days / 30)
frequency = (months, "mon") # type: ignore
frequency = (months, "mon")
elif dt.days >= 1:
frequency = (dt.days, "day") # type: ignore
frequency = (dt.days, "day")
elif dt.seconds >= 3600:
hours = round(dt.seconds / 3600)
frequency = (hours, "hr") # type: ignore
frequency = (hours, "hr")
else:
frequency = (None, "subhr") # type: ignore
frequency = (None, "subhr")

if filename_frequency:
if filename_frequency != frequency:
Expand Down

0 comments on commit aeaa970

Please sign in to comment.