Skip to content

Commit b802cca

Browse files
author
MomIsBestFriend
committed
CLN: Replace isinstace(foo, Class) with isinstance(foo, ABCClass)
1 parent ba08390 commit b802cca

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

pandas/core/arrays/period.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from pandas.core.dtypes.dtypes import PeriodDtype
3434
from pandas.core.dtypes.generic import (
3535
ABCIndexClass,
36+
ABCPeriod,
3637
ABCPeriodArray,
3738
ABCPeriodIndex,
3839
ABCSeries,
@@ -960,8 +961,8 @@ def _get_ordinal_range(start, end, periods, freq, mult=1):
960961
if end is not None:
961962
end = Period(end, freq)
962963

963-
is_start_per = isinstance(start, Period)
964-
is_end_per = isinstance(end, Period)
964+
is_start_per = isinstance(start, ABCPeriod)
965+
is_end_per = isinstance(end, ABCPeriod)
965966

966967
if is_start_per and is_end_per and start.freq != end.freq:
967968
raise ValueError("start and end must have same freq")

pandas/core/indexes/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3582,8 +3582,8 @@ def _join_multi(self, other, how, return_indexers=True):
35823582
if not overlap:
35833583
raise ValueError("cannot join with no overlapping index names")
35843584

3585-
self_is_mi = isinstance(self, MultiIndex)
3586-
other_is_mi = isinstance(other, MultiIndex)
3585+
self_is_mi = isinstance(self, ABCMultiIndex)
3586+
other_is_mi = isinstance(other, ABCMultiIndex)
35873587

35883588
if self_is_mi and other_is_mi:
35893589

pandas/core/reshape/concat.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
concat routines
2+
Concat routines.
33
"""
44

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

99
from pandas._typing import FrameOrSeriesUnion
1010

11+
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
12+
1113
from pandas import DataFrame, Index, MultiIndex, Series
1214
from pandas.core.arrays.categorical import (
1315
factorize_from_iterable,
@@ -394,11 +396,11 @@ def __init__(
394396
axis = sample._get_axis_number(axis)
395397

396398
# Need to flip BlockManager axis in the DataFrame special case
397-
self._is_frame = isinstance(sample, DataFrame)
399+
self._is_frame = isinstance(sample, ABCDataFrame)
398400
if self._is_frame:
399401
axis = 1 if axis == 0 else 0
400402

401-
self._is_series = isinstance(sample, Series)
403+
self._is_series = isinstance(sample, ABCSeries)
402404
if not 0 <= axis <= sample.ndim:
403405
raise AssertionError(
404406
"axis must be between 0 and {ndim}, input was "

pandas/io/formats/excel.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from pandas.core.dtypes import missing
1616
from pandas.core.dtypes.common import is_float, is_scalar
17-
from pandas.core.dtypes.generic import ABCMultiIndex, ABCPeriodIndex
17+
from pandas.core.dtypes.generic import ABCIndex, ABCMultiIndex, ABCPeriodIndex
1818

1919
from pandas import Index
2020
import pandas.core.common as com
@@ -452,7 +452,7 @@ def _format_header_mi(self):
452452
"index ('index'=False) is not yet implemented."
453453
)
454454

455-
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
455+
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
456456
if not (has_aliases or self.header):
457457
return
458458

@@ -500,7 +500,7 @@ def _format_header_mi(self):
500500
self.rowcounter = lnum
501501

502502
def _format_header_regular(self):
503-
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
503+
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
504504
if has_aliases or self.header:
505505
coloffset = 0
506506

@@ -550,7 +550,7 @@ def _format_body(self):
550550
return self._format_regular_rows()
551551

552552
def _format_regular_rows(self):
553-
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
553+
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
554554
if has_aliases or self.header:
555555
self.rowcounter += 1
556556

@@ -590,7 +590,7 @@ def _format_regular_rows(self):
590590
yield cell
591591

592592
def _format_hierarchical_rows(self):
593-
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index))
593+
has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex))
594594
if has_aliases or self.header:
595595
self.rowcounter += 1
596596

0 commit comments

Comments
 (0)