Skip to content

CLN: Replace isinstace(foo, Class) with isinstance(foo, ABCClass) #31535

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 1 commit into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from pandas.core.dtypes.dtypes import PeriodDtype
from pandas.core.dtypes.generic import (
ABCIndexClass,
ABCPeriod,
ABCPeriodArray,
ABCPeriodIndex,
ABCSeries,
Expand Down Expand Up @@ -960,8 +961,8 @@ def _get_ordinal_range(start, end, periods, freq, mult=1):
if end is not None:
end = Period(end, freq)

is_start_per = isinstance(start, Period)
is_end_per = isinstance(end, Period)
is_start_per = isinstance(start, ABCPeriod)
is_end_per = isinstance(end, ABCPeriod)

if is_start_per and is_end_per and start.freq != end.freq:
raise ValueError("start and end must have same freq")
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3582,8 +3582,8 @@ def _join_multi(self, other, how, return_indexers=True):
if not overlap:
raise ValueError("cannot join with no overlapping index names")

self_is_mi = isinstance(self, MultiIndex)
other_is_mi = isinstance(other, MultiIndex)
self_is_mi = isinstance(self, ABCMultiIndex)
other_is_mi = isinstance(other, ABCMultiIndex)

if self_is_mi and other_is_mi:

Expand Down
8 changes: 5 additions & 3 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
concat routines
Concat routines.
"""

from typing import Hashable, Iterable, List, Mapping, Optional, Union, overload
Expand All @@ -8,6 +8,8 @@

from pandas._typing import FrameOrSeriesUnion

from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries

from pandas import DataFrame, Index, MultiIndex, Series
from pandas.core.arrays.categorical import (
factorize_from_iterable,
Expand Down Expand Up @@ -394,11 +396,11 @@ def __init__(
axis = sample._get_axis_number(axis)

# Need to flip BlockManager axis in the DataFrame special case
self._is_frame = isinstance(sample, DataFrame)
self._is_frame = isinstance(sample, ABCDataFrame)
if self._is_frame:
axis = 1 if axis == 0 else 0

self._is_series = isinstance(sample, Series)
self._is_series = isinstance(sample, ABCSeries)
if not 0 <= axis <= sample.ndim:
raise AssertionError(
"axis must be between 0 and {ndim}, input was "
Expand Down
10 changes: 5 additions & 5 deletions pandas/io/formats/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from pandas.core.dtypes import missing
from pandas.core.dtypes.common import is_float, is_scalar
from pandas.core.dtypes.generic import ABCMultiIndex, ABCPeriodIndex
from pandas.core.dtypes.generic import ABCIndex, ABCMultiIndex, ABCPeriodIndex

from pandas import Index
import pandas.core.common as com
Expand Down Expand Up @@ -452,7 +452,7 @@ def _format_header_mi(self):
"index ('index'=False) is not yet implemented."
)

has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
if not (has_aliases or self.header):
return

Expand Down Expand Up @@ -500,7 +500,7 @@ def _format_header_mi(self):
self.rowcounter = lnum

def _format_header_regular(self):
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
if has_aliases or self.header:
coloffset = 0

Expand Down Expand Up @@ -550,7 +550,7 @@ def _format_body(self):
return self._format_regular_rows()

def _format_regular_rows(self):
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
if has_aliases or self.header:
self.rowcounter += 1

Expand Down Expand Up @@ -590,7 +590,7 @@ def _format_regular_rows(self):
yield cell

def _format_hierarchical_rows(self):
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
if has_aliases or self.header:
self.rowcounter += 1

Expand Down