Skip to content

CLN: assorted cleanups #30575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
8ba1bfd
GH ref for 30460
jbrockmendel Dec 26, 2019
e3f453f
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 26, 2019
ba3488c
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 27, 2019
c0e7ec5
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 27, 2019
1484065
whatsnew for 29853
jbrockmendel Dec 27, 2019
8ff540c
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 27, 2019
148dd14
remove validate_cmpress
jbrockmendel Dec 27, 2019
5f945ef
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 28, 2019
580d66c
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 30, 2019
5814a4c
remove defunct comment
jbrockmendel Dec 30, 2019
93ba887
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 30, 2019
79e83fc
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 30, 2019
5eb2772
annotate getattr
jbrockmendel Dec 30, 2019
b74b501
annotations
jbrockmendel Dec 30, 2019
8690600
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 30, 2019
fe1237f
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 30, 2019
e70b940
revert bc mypy doesnt know about warnings.warn
jbrockmendel Dec 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ Datetimelike
- Bug in :class:`DatetimeIndex` addition when adding a non-optimized :class:`DateOffset` incorrectly dropping timezone information (:issue:`30336`)
- Bug in :meth:`DataFrame.drop` where attempting to drop non-existent values from a DatetimeIndex would yield a confusing error message (:issue:`30399`)
- Bug in :meth:`DataFrame.append` would remove the timezone-awareness of new data (:issue:`30238`)
- Bug in :meth:`Series.cummin` and :meth:`Series.cummax` with timezone-aware dtype incorrectly dropping its timezone (:issue:`15553`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is #30460, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

- Bug in :class:`DatetimeArray`, :class:`TimedeltaArray`, and :class:`PeriodArray` where inplace addition and subtraction did not actually operate inplace (:issue:`24115`)

Timedelta
Expand Down
2 changes: 1 addition & 1 deletion pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __setattr__(self, key, val):
else:
raise OptionError("You can only set the value of existing options")

def __getattr__(self, key):
def __getattr__(self, key: str):
prefix = object.__getattribute__(self, "prefix")
if prefix:
prefix += "."
Expand Down
7 changes: 0 additions & 7 deletions pandas/compat/numpy/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ def validate_clip_with_axis(axis, args, kwargs):
return axis


COMPRESS_DEFAULTS: "OrderedDict[str, Any]" = OrderedDict()
COMPRESS_DEFAULTS["axis"] = None
COMPRESS_DEFAULTS["out"] = None
validate_compress = CompatValidator(
COMPRESS_DEFAULTS, fname="compress", method="both", max_fname_arg_count=1
)

CUM_FUNC_DEFAULTS: "OrderedDict[str, Any]" = OrderedDict()
CUM_FUNC_DEFAULTS["dtype"] = None
CUM_FUNC_DEFAULTS["out"] = None
Expand Down
1 change: 1 addition & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11120,6 +11120,7 @@ def cum_func(self, axis=None, skipna=True, *args, **kwargs):
def na_accum_func(blk_values):
# We will be applying this function to block values
if blk_values.dtype.kind in ["m", "M"]:
# GH#30460, GH#29058
# numpy 1.18 started sorting NaTs at the end instead of beginning,
# so we need to work around to maintain backwards-consistency.
orig_dtype = blk_values.dtype
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def f(self):
f.__name__ = "plot"
return self._groupby.apply(f)

def __getattr__(self, name):
def __getattr__(self, name: str):
def attr(*args, **kwargs):
def f(self):
return getattr(self.plot, name)(*args, **kwargs)
Expand Down Expand Up @@ -570,7 +570,7 @@ def _set_result_index_ordered(self, result):
def _dir_additions(self):
return self.obj._dir_additions() | self._apply_whitelist

def __getattr__(self, attr):
def __getattr__(self, attr: str):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
Expand Down
10 changes: 5 additions & 5 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __str__(self) -> str:
)
return f"{type(self).__name__} [{', '.join(attrs)}]"

def __getattr__(self, attr):
def __getattr__(self, attr: str):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self._attributes:
Expand Down Expand Up @@ -131,7 +131,7 @@ def ax(self):
return self.groupby.ax

@property
def _typ(self):
def _typ(self) -> str:
"""
Masquerade for compat as a Series or a DataFrame.
"""
Expand All @@ -140,7 +140,7 @@ def _typ(self):
return "dataframe"

@property
def _from_selection(self):
def _from_selection(self) -> bool:
"""
Is the resampling from a DataFrame column or MultiIndex level.
"""
Expand Down Expand Up @@ -316,7 +316,7 @@ def _downsample(self, f):
def _upsample(self, f, limit=None, fill_value=None):
raise AbstractMethodError(self)

def _gotitem(self, key, ndim, subset=None):
def _gotitem(self, key, ndim: int, subset=None):
"""
Sub-classes to define. Return a sliced object.

Expand Down Expand Up @@ -1407,7 +1407,7 @@ def _get_resampler(self, obj, kind=None):
f"but got an instance of '{type(ax).__name__}'"
)

def _get_grouper(self, obj, validate=True):
def _get_grouper(self, obj, validate: bool = True):
# create the resampler and return our binner
r = self._get_resampler(obj)
r._set_binner()
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ def _get_result_dim(self) -> int:
else:
return self.objs[0].ndim

def _get_new_axes(self):
def _get_new_axes(self) -> List[Index]:
ndim = self._get_result_dim()
new_axes = [None] * ndim
new_axes: List = [None] * ndim
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add type parameters at some point. xref #30539


for i in range(ndim):
if i == self.axis:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _gotitem(self, key, ndim, subset=None):
self._selection = key
return self

def __getattr__(self, attr):
def __getattr__(self, attr: str):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/indexes/datetimes/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ def test_constructor_timestamp_near_dst(self):
expected = DatetimeIndex([ts[0].to_pydatetime(), ts[1].to_pydatetime()])
tm.assert_index_equal(result, expected)

# TODO(GH-24559): Remove the xfail for the tz-aware case.
@pytest.mark.parametrize("klass", [Index, DatetimeIndex])
@pytest.mark.parametrize("box", [np.array, partial(np.array, dtype=object), list])
@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/_depr_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __repr__(self) -> str:

__str__ = __repr__

def __getattr__(self, name):
def __getattr__(self, name: str):
if name in self.self_dir:
return object.__getattribute__(self, name)

Expand Down