Skip to content

Commit 17d19c4

Browse files
jbrockmendelsimonjayhawkins
authored andcommitted
CLN: assorted cleanups (#30575)
1 parent cfffad9 commit 17d19c4

File tree

10 files changed

+14
-20
lines changed

10 files changed

+14
-20
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ Datetimelike
794794
- Bug in :class:`DatetimeIndex` addition when adding a non-optimized :class:`DateOffset` incorrectly dropping timezone information (:issue:`30336`)
795795
- Bug in :meth:`DataFrame.drop` where attempting to drop non-existent values from a DatetimeIndex would yield a confusing error message (:issue:`30399`)
796796
- Bug in :meth:`DataFrame.append` would remove the timezone-awareness of new data (:issue:`30238`)
797+
- Bug in :meth:`Series.cummin` and :meth:`Series.cummax` with timezone-aware dtype incorrectly dropping its timezone (:issue:`15553`)
797798
- Bug in :class:`DatetimeArray`, :class:`TimedeltaArray`, and :class:`PeriodArray` where inplace addition and subtraction did not actually operate inplace (:issue:`24115`)
798799

799800
Timedelta

pandas/_config/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def __setattr__(self, key, val):
197197
else:
198198
raise OptionError("You can only set the value of existing options")
199199

200-
def __getattr__(self, key):
200+
def __getattr__(self, key: str):
201201
prefix = object.__getattribute__(self, "prefix")
202202
if prefix:
203203
prefix += "."

pandas/compat/numpy/function.py

-7
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,6 @@ def validate_clip_with_axis(axis, args, kwargs):
169169
return axis
170170

171171

172-
COMPRESS_DEFAULTS: "OrderedDict[str, Any]" = OrderedDict()
173-
COMPRESS_DEFAULTS["axis"] = None
174-
COMPRESS_DEFAULTS["out"] = None
175-
validate_compress = CompatValidator(
176-
COMPRESS_DEFAULTS, fname="compress", method="both", max_fname_arg_count=1
177-
)
178-
179172
CUM_FUNC_DEFAULTS: "OrderedDict[str, Any]" = OrderedDict()
180173
CUM_FUNC_DEFAULTS["dtype"] = None
181174
CUM_FUNC_DEFAULTS["out"] = None

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -11120,6 +11120,7 @@ def cum_func(self, axis=None, skipna=True, *args, **kwargs):
1112011120
def na_accum_func(blk_values):
1112111121
# We will be applying this function to block values
1112211122
if blk_values.dtype.kind in ["m", "M"]:
11123+
# GH#30460, GH#29058
1112311124
# numpy 1.18 started sorting NaTs at the end instead of beginning,
1112411125
# so we need to work around to maintain backwards-consistency.
1112511126
orig_dtype = blk_values.dtype

pandas/core/groupby/groupby.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def f(self):
325325
f.__name__ = "plot"
326326
return self._groupby.apply(f)
327327

328-
def __getattr__(self, name):
328+
def __getattr__(self, name: str):
329329
def attr(*args, **kwargs):
330330
def f(self):
331331
return getattr(self.plot, name)(*args, **kwargs)
@@ -570,7 +570,7 @@ def _set_result_index_ordered(self, result):
570570
def _dir_additions(self):
571571
return self.obj._dir_additions() | self._apply_whitelist
572572

573-
def __getattr__(self, attr):
573+
def __getattr__(self, attr: str):
574574
if attr in self._internal_names_set:
575575
return object.__getattribute__(self, attr)
576576
if attr in self.obj:

pandas/core/resample.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __str__(self) -> str:
9696
)
9797
return f"{type(self).__name__} [{', '.join(attrs)}]"
9898

99-
def __getattr__(self, attr):
99+
def __getattr__(self, attr: str):
100100
if attr in self._internal_names_set:
101101
return object.__getattribute__(self, attr)
102102
if attr in self._attributes:
@@ -131,7 +131,7 @@ def ax(self):
131131
return self.groupby.ax
132132

133133
@property
134-
def _typ(self):
134+
def _typ(self) -> str:
135135
"""
136136
Masquerade for compat as a Series or a DataFrame.
137137
"""
@@ -140,7 +140,7 @@ def _typ(self):
140140
return "dataframe"
141141

142142
@property
143-
def _from_selection(self):
143+
def _from_selection(self) -> bool:
144144
"""
145145
Is the resampling from a DataFrame column or MultiIndex level.
146146
"""
@@ -316,7 +316,7 @@ def _downsample(self, f):
316316
def _upsample(self, f, limit=None, fill_value=None):
317317
raise AbstractMethodError(self)
318318

319-
def _gotitem(self, key, ndim, subset=None):
319+
def _gotitem(self, key, ndim: int, subset=None):
320320
"""
321321
Sub-classes to define. Return a sliced object.
322322
@@ -1407,7 +1407,7 @@ def _get_resampler(self, obj, kind=None):
14071407
f"but got an instance of '{type(ax).__name__}'"
14081408
)
14091409

1410-
def _get_grouper(self, obj, validate=True):
1410+
def _get_grouper(self, obj, validate: bool = True):
14111411
# create the resampler and return our binner
14121412
r = self._get_resampler(obj)
14131413
r._set_binner()

pandas/core/reshape/concat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,9 @@ def _get_result_dim(self) -> int:
472472
else:
473473
return self.objs[0].ndim
474474

475-
def _get_new_axes(self):
475+
def _get_new_axes(self) -> List[Index]:
476476
ndim = self._get_result_dim()
477-
new_axes = [None] * ndim
477+
new_axes: List = [None] * ndim
478478

479479
for i in range(ndim):
480480
if i == self.axis:

pandas/core/window/rolling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _gotitem(self, key, ndim, subset=None):
184184
self._selection = key
185185
return self
186186

187-
def __getattr__(self, attr):
187+
def __getattr__(self, attr: str):
188188
if attr in self._internal_names_set:
189189
return object.__getattribute__(self, attr)
190190
if attr in self.obj:

pandas/tests/indexes/datetimes/test_constructors.py

-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ def test_constructor_timestamp_near_dst(self):
711711
expected = DatetimeIndex([ts[0].to_pydatetime(), ts[1].to_pydatetime()])
712712
tm.assert_index_equal(result, expected)
713713

714-
# TODO(GH-24559): Remove the xfail for the tz-aware case.
715714
@pytest.mark.parametrize("klass", [Index, DatetimeIndex])
716715
@pytest.mark.parametrize("box", [np.array, partial(np.array, dtype=object), list])
717716
@pytest.mark.parametrize(

pandas/util/_depr_module.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __repr__(self) -> str:
4646

4747
__str__ = __repr__
4848

49-
def __getattr__(self, name):
49+
def __getattr__(self, name: str):
5050
if name in self.self_dir:
5151
return object.__getattribute__(self, name)
5252

0 commit comments

Comments
 (0)