|
45 | 45 | from datetime import datetime, timedelta |
46 | 46 | from enum import Enum |
47 | 47 | from functools import partial |
48 | | -from typing import ClassVar |
| 48 | +from typing import TYPE_CHECKING, ClassVar |
49 | 49 |
|
50 | 50 | import numpy as np |
51 | 51 | import pandas as pd |
|
67 | 67 | cftime = None |
68 | 68 |
|
69 | 69 |
|
| 70 | +if TYPE_CHECKING: |
| 71 | + from xarray.core.types import InclusiveOptions, SideOptions |
| 72 | + |
| 73 | + |
70 | 74 | def get_date_type(calendar, use_cftime=True): |
71 | 75 | """Return the cftime date type for a given calendar name.""" |
72 | 76 | if cftime is None: |
@@ -903,8 +907,8 @@ def cftime_range( |
903 | 907 | freq="D", |
904 | 908 | normalize=False, |
905 | 909 | name=None, |
906 | | - closed=_NoDefault, |
907 | | - inclusive=None, |
| 910 | + closed: _NoDefault | SideOptions = _NoDefault, |
| 911 | + inclusive: None | InclusiveOptions = None, |
908 | 912 | calendar="standard", |
909 | 913 | ): |
910 | 914 | """Return a fixed frequency CFTimeIndex. |
@@ -945,23 +949,22 @@ def cftime_range( |
945 | 949 | Notes |
946 | 950 | ----- |
947 | 951 | This function is an analog of ``pandas.date_range`` for use in generating |
948 | | - sequences of ``cftime.datetime`` objects. It supports most of the features |
949 | | - of ``pandas.date_range`` (e.g. specifying how the index is ``closed`` on |
950 | | - either side, or whether or not to ``normalize`` the start and end bounds); |
951 | | - however, there are some notable exceptions: |
952 | | -
|
| 952 | + sequences of ``cftime.datetime`` objects. It supports most of the |
| 953 | + features of ``pandas.date_range`` (e.g. specifying how the index is |
| 954 | + ``closed`` on either side, or whether or not to ``normalize`` the start and |
| 955 | + end bounds); however, there are some notable exceptions: |
953 | 956 | - You cannot specify a ``tz`` (time zone) argument. |
954 | 957 | - Start or end dates specified as partial-datetime strings must use the |
955 | 958 | `ISO-8601 format <https://en.wikipedia.org/wiki/ISO_8601>`_. |
956 | 959 | - It supports many, but not all, frequencies supported by |
957 | 960 | ``pandas.date_range``. For example it does not currently support any of |
958 | 961 | the business-related or semi-monthly frequencies. |
959 | 962 | - Compound sub-monthly frequencies are not supported, e.g. '1H1min', as |
960 | | - these can easily be written in terms of the finest common resolution, e.g. |
961 | | - '61min'. |
| 963 | + these can easily be written in terms of the finest common resolution, |
| 964 | + e.g. '61min'. |
962 | 965 |
|
963 | | - Valid simple frequency strings for use with ``cftime``-calendars include any |
964 | | - multiples of the following. |
| 966 | + Valid simple frequency strings for use with ``cftime``-calendars include |
| 967 | + any multiples of the following. |
965 | 968 |
|
966 | 969 | +--------+--------------------------+ |
967 | 970 | | Alias | Description | |
@@ -1140,8 +1143,8 @@ def date_range( |
1140 | 1143 | tz=None, |
1141 | 1144 | normalize=False, |
1142 | 1145 | name=None, |
1143 | | - closed=_NoDefault, |
1144 | | - inclusive=None, |
| 1146 | + closed: _NoDefault | SideOptions = _NoDefault, |
| 1147 | + inclusive: None | InclusiveOptions = None, |
1145 | 1148 | calendar="standard", |
1146 | 1149 | use_cftime=None, |
1147 | 1150 | ): |
|
0 commit comments