Skip to content

Commit 7e680a6

Browse files
simonjayhawkinsKevin D Smith
authored and
Kevin D Smith
committed
TYP: check_untyped_defs core.arrays.base (pandas-dev#36885)
1 parent 78d6955 commit 7e680a6

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

pandas/core/arrays/base.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -1176,48 +1176,48 @@ def _create_arithmetic_method(cls, op):
11761176

11771177
@classmethod
11781178
def _add_arithmetic_ops(cls):
1179-
cls.__add__ = cls._create_arithmetic_method(operator.add)
1180-
cls.__radd__ = cls._create_arithmetic_method(ops.radd)
1181-
cls.__sub__ = cls._create_arithmetic_method(operator.sub)
1182-
cls.__rsub__ = cls._create_arithmetic_method(ops.rsub)
1183-
cls.__mul__ = cls._create_arithmetic_method(operator.mul)
1184-
cls.__rmul__ = cls._create_arithmetic_method(ops.rmul)
1185-
cls.__pow__ = cls._create_arithmetic_method(operator.pow)
1186-
cls.__rpow__ = cls._create_arithmetic_method(ops.rpow)
1187-
cls.__mod__ = cls._create_arithmetic_method(operator.mod)
1188-
cls.__rmod__ = cls._create_arithmetic_method(ops.rmod)
1189-
cls.__floordiv__ = cls._create_arithmetic_method(operator.floordiv)
1190-
cls.__rfloordiv__ = cls._create_arithmetic_method(ops.rfloordiv)
1191-
cls.__truediv__ = cls._create_arithmetic_method(operator.truediv)
1192-
cls.__rtruediv__ = cls._create_arithmetic_method(ops.rtruediv)
1193-
cls.__divmod__ = cls._create_arithmetic_method(divmod)
1194-
cls.__rdivmod__ = cls._create_arithmetic_method(ops.rdivmod)
1179+
setattr(cls, "__add__", cls._create_arithmetic_method(operator.add))
1180+
setattr(cls, "__radd__", cls._create_arithmetic_method(ops.radd))
1181+
setattr(cls, "__sub__", cls._create_arithmetic_method(operator.sub))
1182+
setattr(cls, "__rsub__", cls._create_arithmetic_method(ops.rsub))
1183+
setattr(cls, "__mul__", cls._create_arithmetic_method(operator.mul))
1184+
setattr(cls, "__rmul__", cls._create_arithmetic_method(ops.rmul))
1185+
setattr(cls, "__pow__", cls._create_arithmetic_method(operator.pow))
1186+
setattr(cls, "__rpow__", cls._create_arithmetic_method(ops.rpow))
1187+
setattr(cls, "__mod__", cls._create_arithmetic_method(operator.mod))
1188+
setattr(cls, "__rmod__", cls._create_arithmetic_method(ops.rmod))
1189+
setattr(cls, "__floordiv__", cls._create_arithmetic_method(operator.floordiv))
1190+
setattr(cls, "__rfloordiv__", cls._create_arithmetic_method(ops.rfloordiv))
1191+
setattr(cls, "__truediv__", cls._create_arithmetic_method(operator.truediv))
1192+
setattr(cls, "__rtruediv__", cls._create_arithmetic_method(ops.rtruediv))
1193+
setattr(cls, "__divmod__", cls._create_arithmetic_method(divmod))
1194+
setattr(cls, "__rdivmod__", cls._create_arithmetic_method(ops.rdivmod))
11951195

11961196
@classmethod
11971197
def _create_comparison_method(cls, op):
11981198
raise AbstractMethodError(cls)
11991199

12001200
@classmethod
12011201
def _add_comparison_ops(cls):
1202-
cls.__eq__ = cls._create_comparison_method(operator.eq)
1203-
cls.__ne__ = cls._create_comparison_method(operator.ne)
1204-
cls.__lt__ = cls._create_comparison_method(operator.lt)
1205-
cls.__gt__ = cls._create_comparison_method(operator.gt)
1206-
cls.__le__ = cls._create_comparison_method(operator.le)
1207-
cls.__ge__ = cls._create_comparison_method(operator.ge)
1202+
setattr(cls, "__eq__", cls._create_comparison_method(operator.eq))
1203+
setattr(cls, "__ne__", cls._create_comparison_method(operator.ne))
1204+
setattr(cls, "__lt__", cls._create_comparison_method(operator.lt))
1205+
setattr(cls, "__gt__", cls._create_comparison_method(operator.gt))
1206+
setattr(cls, "__le__", cls._create_comparison_method(operator.le))
1207+
setattr(cls, "__ge__", cls._create_comparison_method(operator.ge))
12081208

12091209
@classmethod
12101210
def _create_logical_method(cls, op):
12111211
raise AbstractMethodError(cls)
12121212

12131213
@classmethod
12141214
def _add_logical_ops(cls):
1215-
cls.__and__ = cls._create_logical_method(operator.and_)
1216-
cls.__rand__ = cls._create_logical_method(ops.rand_)
1217-
cls.__or__ = cls._create_logical_method(operator.or_)
1218-
cls.__ror__ = cls._create_logical_method(ops.ror_)
1219-
cls.__xor__ = cls._create_logical_method(operator.xor)
1220-
cls.__rxor__ = cls._create_logical_method(ops.rxor)
1215+
setattr(cls, "__and__", cls._create_logical_method(operator.and_))
1216+
setattr(cls, "__rand__", cls._create_logical_method(ops.rand_))
1217+
setattr(cls, "__or__", cls._create_logical_method(operator.or_))
1218+
setattr(cls, "__ror__", cls._create_logical_method(ops.ror_))
1219+
setattr(cls, "__xor__", cls._create_logical_method(operator.xor))
1220+
setattr(cls, "__rxor__", cls._create_logical_method(ops.rxor))
12211221

12221222

12231223
class ExtensionScalarOpsMixin(ExtensionOpsMixin):

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ check_untyped_defs=False
142142
[mypy-pandas.core.apply]
143143
check_untyped_defs=False
144144

145-
[mypy-pandas.core.arrays.base]
146-
check_untyped_defs=False
147-
148145
[mypy-pandas.core.arrays.datetimelike]
149146
check_untyped_defs=False
150147

0 commit comments

Comments
 (0)