Skip to content

Commit b81a21f

Browse files
committed
CLN: Cleanup use of super() in instance methods.
1 parent b62e9ae commit b81a21f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+419
-518
lines changed

asv_bench/benchmarks/io/stata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def time_write_stata(self, convert_dates):
3838

3939
class StataMissing(Stata):
4040
def setup(self, convert_dates):
41-
super(StataMissing, self).setup(convert_dates)
41+
super().setup(convert_dates)
4242
for i in range(10):
4343
missing_data = np.random.randn(self.N)
4444
missing_data[missing_data < 0] = np.nan

pandas/_libs/tslibs/strptime.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ class TimeRE(dict):
528528
self.locale_time = locale_time
529529
else:
530530
self.locale_time = LocaleTime()
531-
base = super(TimeRE, self)
531+
base = super()
532532
base.__init__({
533533
# The " \d" part of the regex is to make %c from ANSI C work
534534
'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])",

pandas/compat/pickle_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def find_class(self, module, name):
144144
# override superclass
145145
key = (module, name)
146146
module, name = _class_locations_map.get(key, key)
147-
return super(Unpickler, self).find_class(module, name)
147+
return super().find_class(module, name)
148148

149149

150150
Unpickler.dispatch = copy.copy(Unpickler.dispatch)

pandas/core/algorithms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ class SelectNFrame(SelectN):
11591159
"""
11601160

11611161
def __init__(self, obj, n, keep, columns):
1162-
super(SelectNFrame, self).__init__(obj, n, keep)
1162+
super().__init__(obj, n, keep)
11631163
if not is_list_like(columns) or isinstance(columns, tuple):
11641164
columns = [columns]
11651165
columns = list(columns)

pandas/core/apply.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class FrameRowApply(FrameApply):
317317
axis = 0
318318

319319
def apply_broadcast(self):
320-
return super(FrameRowApply, self).apply_broadcast(self.obj)
320+
return super().apply_broadcast(self.obj)
321321

322322
@property
323323
def series_generator(self):
@@ -356,7 +356,7 @@ class FrameColumnApply(FrameApply):
356356
axis = 1
357357

358358
def apply_broadcast(self):
359-
result = super(FrameColumnApply, self).apply_broadcast(self.obj.T)
359+
result = super().apply_broadcast(self.obj.T)
360360
return result.T
361361

362362
@property

pandas/core/arrays/categorical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ def argsort(self, *args, **kwargs):
15491549
array([3, 0, 1, 2])
15501550
"""
15511551
# Keep the implementation here just for the docstring.
1552-
return super(Categorical, self).argsort(*args, **kwargs)
1552+
return super().argsort(*args, **kwargs)
15531553

15541554
def sort_values(self, inplace=False, ascending=True, na_position='last'):
15551555
"""

pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,9 +1381,7 @@ def _reduce(self, name, axis=0, skipna=True, **kwargs):
13811381
if op:
13821382
return op(axis=axis, skipna=skipna, **kwargs)
13831383
else:
1384-
return super(DatetimeLikeArrayMixin, self)._reduce(
1385-
name, skipna, **kwargs
1386-
)
1384+
return super()._reduce(name, skipna, **kwargs)
13871385

13881386
def min(self, axis=None, skipna=True, *args, **kwargs):
13891387
"""

pandas/core/arrays/datetimes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def __array__(self, dtype=None):
580580
# The default for tz-aware is object, to preserve tz info
581581
dtype = object
582582

583-
return super(DatetimeArray, self).__array__(dtype=dtype)
583+
return super().__array__(dtype=dtype)
584584

585585
def __iter__(self):
586586
"""
@@ -771,7 +771,7 @@ def _add_delta(self, delta):
771771
-------
772772
result : DatetimeArray
773773
"""
774-
new_values = super(DatetimeArray, self)._add_delta(delta)
774+
new_values = super()._add_delta(delta)
775775
return type(self)._from_sequence(new_values, tz=self.tz, freq='infer')
776776

777777
# -----------------------------------------------------------------

pandas/core/arrays/period.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def astype(self, dtype, copy=True):
505505

506506
if is_period_dtype(dtype):
507507
return self.asfreq(dtype.freq)
508-
return super(PeriodArray, self).astype(dtype, copy=copy)
508+
return super().astype(dtype, copy=copy)
509509

510510
@property
511511
def flags(self):
@@ -560,7 +560,7 @@ def _add_offset(self, other):
560560
# Note: when calling parent class's _add_timedeltalike_scalar,
561561
# it will call delta_to_nanoseconds(delta). Because delta here
562562
# is an integer, delta_to_nanoseconds will return it unchanged.
563-
result = super(PeriodArray, self)._add_timedeltalike_scalar(other.n)
563+
result = super()._add_timedeltalike_scalar(other.n)
564564
return type(self)(result, freq=self.freq)
565565

566566
def _add_timedeltalike_scalar(self, other):
@@ -584,7 +584,7 @@ def _add_timedeltalike_scalar(self, other):
584584
# Note: when calling parent class's _add_timedeltalike_scalar,
585585
# it will call delta_to_nanoseconds(delta). Because delta here
586586
# is an integer, delta_to_nanoseconds will return it unchanged.
587-
ordinals = super(PeriodArray, self)._add_timedeltalike_scalar(other)
587+
ordinals = super()._add_timedeltalike_scalar(other)
588588
return ordinals
589589

590590
def _add_delta_tdi(self, other):
@@ -620,7 +620,7 @@ def _add_delta(self, other):
620620
# We cannot add timedelta-like to non-tick PeriodArray
621621
_raise_on_incompatible(self, other)
622622

623-
new_ordinals = super(PeriodArray, self)._add_delta(other)
623+
new_ordinals = super()._add_delta(other)
624624
return type(self)(new_ordinals, freq=self.freq)
625625

626626
def _check_timedeltalike_freq_compat(self, other):

pandas/core/arrays/sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(
118118
def __hash__(self):
119119
# Python3 doesn't inherit __hash__ when a base class overrides
120120
# __eq__, so we explicitly do it here.
121-
return super(SparseDtype, self).__hash__()
121+
return super().__hash__()
122122

123123
def __eq__(self, other):
124124
# We have to override __eq__ to handle NA values in _metadata.

0 commit comments

Comments
 (0)