|
1 | 1 | """
|
2 | 2 | datetimelike delegation
|
3 | 3 | """
|
| 4 | +from typing import TYPE_CHECKING |
| 5 | + |
4 | 6 | import numpy as np
|
5 | 7 |
|
6 | 8 | from pandas.core.dtypes.common import (
|
|
21 | 23 | from pandas.core.indexes.datetimes import DatetimeIndex
|
22 | 24 | from pandas.core.indexes.timedeltas import TimedeltaIndex
|
23 | 25 |
|
| 26 | +if TYPE_CHECKING: |
| 27 | + from pandas import Series # noqa:F401 |
| 28 | + |
24 | 29 |
|
25 | 30 | class Properties(PandasDelegate, PandasObject, NoNewAttributesMixin):
|
26 |
| - def __init__(self, data, orig): |
| 31 | + def __init__(self, data: "Series", orig): |
27 | 32 | if not isinstance(data, ABCSeries):
|
28 | 33 | raise TypeError(
|
29 | 34 | f"cannot convert an object of type {type(data)} to a datetimelike index"
|
@@ -137,7 +142,7 @@ class DatetimeProperties(Properties):
|
137 | 142 | Raises TypeError if the Series does not contain datetimelike values.
|
138 | 143 | """
|
139 | 144 |
|
140 |
| - def to_pydatetime(self): |
| 145 | + def to_pydatetime(self) -> np.ndarray: |
141 | 146 | """
|
142 | 147 | Return the data as an array of native Python datetime objects.
|
143 | 148 |
|
@@ -209,7 +214,7 @@ class TimedeltaProperties(Properties):
|
209 | 214 | Raises TypeError if the Series does not contain datetimelike values.
|
210 | 215 | """
|
211 | 216 |
|
212 |
| - def to_pytimedelta(self): |
| 217 | + def to_pytimedelta(self) -> np.ndarray: |
213 | 218 | """
|
214 | 219 | Return an array of native `datetime.timedelta` objects.
|
215 | 220 |
|
@@ -271,7 +276,7 @@ def components(self):
|
271 | 276 | 2 0 0 0 2 0 0 0
|
272 | 277 | 3 0 0 0 3 0 0 0
|
273 | 278 | 4 0 0 0 4 0 0 0
|
274 |
| - """ # noqa: E501 |
| 279 | + """ |
275 | 280 | return self._get_values().components.set_index(self._parent.index)
|
276 | 281 |
|
277 | 282 | @property
|
@@ -303,7 +308,7 @@ class PeriodProperties(Properties):
|
303 | 308 | class CombinedDatetimelikeProperties(
|
304 | 309 | DatetimeProperties, TimedeltaProperties, PeriodProperties
|
305 | 310 | ):
|
306 |
| - def __new__(cls, data): |
| 311 | + def __new__(cls, data: "Series"): |
307 | 312 | # CombinedDatetimelikeProperties isn't really instantiated. Instead
|
308 | 313 | # we need to choose which parent (datetime or timedelta) is
|
309 | 314 | # appropriate. Since we're checking the dtypes anyway, we'll just
|
|
0 commit comments