Skip to content

Commit ca7a15f

Browse files
check_untyped_defs pandas.core.resample
1 parent 931bd29 commit ca7a15f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

pandas/core/resample.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import copy
22
from datetime import timedelta
33
from textwrap import dedent
4-
from typing import Dict, no_type_check
4+
from typing import TYPE_CHECKING, Dict, no_type_check
55
import warnings
66

77
import numpy as np
@@ -410,7 +410,8 @@ def _wrap_result(self, result):
410410
if isinstance(result, ABCSeries) and result.empty:
411411
obj = self.obj
412412
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
414415
else:
415416
result.index = obj.index._shallow_copy(freq=self.freq)
416417
result.name = getattr(obj, "name", None)
@@ -978,7 +979,13 @@ def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None):
978979
return r
979980

980981

981-
class _GroupByMixin(GroupByMixin):
982+
if TYPE_CHECKING:
983+
_Base = Resampler
984+
else:
985+
_Base = object
986+
987+
988+
class _GroupByMixin(GroupByMixin, _Base):
982989
"""
983990
Provide the groupby facilities.
984991
"""
@@ -1572,7 +1579,8 @@ def _get_period_bins(self, ax):
15721579
"an instance of %r" % type(ax).__name__
15731580
)
15741581

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
15761584

15771585
# NaT handling as in pandas._lib.lib.generate_bins_dt64()
15781586
nat_count = 0
@@ -1810,7 +1818,8 @@ def asfreq(obj, freq, method=None, how=None, normalize=False, fill_value=None):
18101818
how = "E"
18111819

18121820
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
18141823

18151824
elif len(obj.index) == 0:
18161825
new_obj = obj.copy()

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ check_untyped_defs=False
233233
[mypy-pandas.core.nanops]
234234
check_untyped_defs=False
235235

236-
[mypy-pandas.core.resample]
237-
check_untyped_defs=False
238-
239236
[mypy-pandas.core.reshape.merge]
240237
check_untyped_defs=False
241238

0 commit comments

Comments
 (0)