|
1 | 1 | import copy
|
2 | 2 | from datetime import timedelta
|
3 | 3 | from textwrap import dedent
|
4 |
| -from typing import Dict, no_type_check |
| 4 | +from typing import TYPE_CHECKING, Dict, no_type_check |
5 | 5 | import warnings
|
6 | 6 |
|
7 | 7 | import numpy as np
|
@@ -410,7 +410,8 @@ def _wrap_result(self, result):
|
410 | 410 | if isinstance(result, ABCSeries) and result.empty:
|
411 | 411 | obj = self.obj
|
412 | 412 | if isinstance(obj.index, PeriodIndex):
|
413 |
| - result.index = obj.index.asfreq(self.freq) |
| 413 | + # error: "PeriodIndex" has no attribute "asfreq" |
| 414 | + result.index = obj.index.asfreq(self.freq) # type: ignore |
414 | 415 | else:
|
415 | 416 | result.index = obj.index._shallow_copy(freq=self.freq)
|
416 | 417 | result.name = getattr(obj, "name", None)
|
@@ -978,7 +979,13 @@ def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None):
|
978 | 979 | return r
|
979 | 980 |
|
980 | 981 |
|
981 |
| -class _GroupByMixin(GroupByMixin): |
| 982 | +if TYPE_CHECKING: |
| 983 | + _Base = Resampler |
| 984 | +else: |
| 985 | + _Base = object |
| 986 | + |
| 987 | + |
| 988 | +class _GroupByMixin(GroupByMixin, _Base): |
982 | 989 | """
|
983 | 990 | Provide the groupby facilities.
|
984 | 991 | """
|
@@ -1572,7 +1579,8 @@ def _get_period_bins(self, ax):
|
1572 | 1579 | "an instance of %r" % type(ax).__name__
|
1573 | 1580 | )
|
1574 | 1581 |
|
1575 |
| - memb = ax.asfreq(self.freq, how=self.convention) |
| 1582 | + # error: "PeriodIndex" has no attribute "asfreq" |
| 1583 | + memb = ax.asfreq(self.freq, how=self.convention) # type: ignore |
1576 | 1584 |
|
1577 | 1585 | # NaT handling as in pandas._lib.lib.generate_bins_dt64()
|
1578 | 1586 | nat_count = 0
|
@@ -1810,7 +1818,8 @@ def asfreq(obj, freq, method=None, how=None, normalize=False, fill_value=None):
|
1810 | 1818 | how = "E"
|
1811 | 1819 |
|
1812 | 1820 | new_obj = obj.copy()
|
1813 |
| - new_obj.index = obj.index.asfreq(freq, how=how) |
| 1821 | + # error: "PeriodIndex" has no attribute "asfreq" |
| 1822 | + new_obj.index = obj.index.asfreq(freq, how=how) # type: ignore |
1814 | 1823 |
|
1815 | 1824 | elif len(obj.index) == 0:
|
1816 | 1825 | new_obj = obj.copy()
|
|
0 commit comments