Skip to content

Commit 1c38dfa

Browse files
TYP: remove ignores for "Cannot assign to a method" (#40265)
1 parent 8e0b744 commit 1c38dfa

File tree

1 file changed

+18
-40
lines changed

1 file changed

+18
-40
lines changed

pandas/core/generic.py

+18-40
Original file line numberDiff line numberDiff line change
@@ -10601,8 +10601,7 @@ def _add_numeric_operations(cls):
1060110601
def any(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
1060210602
return NDFrame.any(self, axis, bool_only, skipna, level, **kwargs)
1060310603

10604-
# error: Cannot assign to a method
10605-
cls.any = any # type: ignore[assignment]
10604+
setattr(cls, "any", any)
1060610605

1060710606
@doc(
1060810607
_bool_doc,
@@ -10617,12 +10616,7 @@ def any(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
1061710616
def all(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
1061810617
return NDFrame.all(self, axis, bool_only, skipna, level, **kwargs)
1061910618

10620-
# error: Cannot assign to a method
10621-
10622-
# error: Incompatible types in assignment (expression has type
10623-
# "Callable[[Iterable[object]], bool]", variable has type "Callable[[NDFrame,
10624-
# Any, Any, Any, Any, KwArg(Any)], Any]")
10625-
cls.all = all # type: ignore[assignment]
10619+
setattr(cls, "all", all)
1062610620

1062710621
# error: Argument 1 to "doc" has incompatible type "Optional[str]"; expected
1062810622
# "Union[str, Callable[..., Any]]"
@@ -10639,8 +10633,7 @@ def all(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
1063910633
def mad(self, axis=None, skipna=None, level=None):
1064010634
return NDFrame.mad(self, axis, skipna, level)
1064110635

10642-
# error: Cannot assign to a method
10643-
cls.mad = mad # type: ignore[assignment]
10636+
setattr(cls, "mad", mad)
1064410637

1064510638
@doc(
1064610639
_num_ddof_doc,
@@ -10662,8 +10655,7 @@ def sem(
1066210655
):
1066310656
return NDFrame.sem(self, axis, skipna, level, ddof, numeric_only, **kwargs)
1066410657

10665-
# error: Cannot assign to a method
10666-
cls.sem = sem # type: ignore[assignment]
10658+
setattr(cls, "sem", sem)
1066710659

1066810660
@doc(
1066910661
_num_ddof_doc,
@@ -10684,8 +10676,7 @@ def var(
1068410676
):
1068510677
return NDFrame.var(self, axis, skipna, level, ddof, numeric_only, **kwargs)
1068610678

10687-
# error: Cannot assign to a method
10688-
cls.var = var # type: ignore[assignment]
10679+
setattr(cls, "var", var)
1068910680

1069010681
@doc(
1069110682
_num_ddof_doc,
@@ -10707,8 +10698,7 @@ def std(
1070710698
):
1070810699
return NDFrame.std(self, axis, skipna, level, ddof, numeric_only, **kwargs)
1070910700

10710-
# error: Cannot assign to a method
10711-
cls.std = std # type: ignore[assignment]
10701+
setattr(cls, "std", std)
1071210702

1071310703
@doc(
1071410704
_cnum_doc,
@@ -10722,8 +10712,7 @@ def std(
1072210712
def cummin(self, axis=None, skipna=True, *args, **kwargs):
1072310713
return NDFrame.cummin(self, axis, skipna, *args, **kwargs)
1072410714

10725-
# error: Cannot assign to a method
10726-
cls.cummin = cummin # type: ignore[assignment]
10715+
setattr(cls, "cummin", cummin)
1072710716

1072810717
@doc(
1072910718
_cnum_doc,
@@ -10737,8 +10726,7 @@ def cummin(self, axis=None, skipna=True, *args, **kwargs):
1073710726
def cummax(self, axis=None, skipna=True, *args, **kwargs):
1073810727
return NDFrame.cummax(self, axis, skipna, *args, **kwargs)
1073910728

10740-
# error: Cannot assign to a method
10741-
cls.cummax = cummax # type: ignore[assignment]
10729+
setattr(cls, "cummax", cummax)
1074210730

1074310731
@doc(
1074410732
_cnum_doc,
@@ -10752,8 +10740,7 @@ def cummax(self, axis=None, skipna=True, *args, **kwargs):
1075210740
def cumsum(self, axis=None, skipna=True, *args, **kwargs):
1075310741
return NDFrame.cumsum(self, axis, skipna, *args, **kwargs)
1075410742

10755-
# error: Cannot assign to a method
10756-
cls.cumsum = cumsum # type: ignore[assignment]
10743+
setattr(cls, "cumsum", cumsum)
1075710744

1075810745
@doc(
1075910746
_cnum_doc,
@@ -10767,8 +10754,7 @@ def cumsum(self, axis=None, skipna=True, *args, **kwargs):
1076710754
def cumprod(self, axis=None, skipna=True, *args, **kwargs):
1076810755
return NDFrame.cumprod(self, axis, skipna, *args, **kwargs)
1076910756

10770-
# error: Cannot assign to a method
10771-
cls.cumprod = cumprod # type: ignore[assignment]
10757+
setattr(cls, "cumprod", cumprod)
1077210758

1077310759
@doc(
1077410760
_num_doc,
@@ -10794,8 +10780,7 @@ def sum(
1079410780
self, axis, skipna, level, numeric_only, min_count, **kwargs
1079510781
)
1079610782

10797-
# error: Cannot assign to a method
10798-
cls.sum = sum # type: ignore[assignment]
10783+
setattr(cls, "sum", sum)
1079910784

1080010785
@doc(
1080110786
_num_doc,
@@ -10820,8 +10805,7 @@ def prod(
1082010805
self, axis, skipna, level, numeric_only, min_count, **kwargs
1082110806
)
1082210807

10823-
# error: Cannot assign to a method
10824-
cls.prod = prod # type: ignore[assignment]
10808+
setattr(cls, "prod", prod)
1082510809
cls.product = prod
1082610810

1082710811
@doc(
@@ -10837,8 +10821,7 @@ def prod(
1083710821
def mean(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1083810822
return NDFrame.mean(self, axis, skipna, level, numeric_only, **kwargs)
1083910823

10840-
# error: Cannot assign to a method
10841-
cls.mean = mean # type: ignore[assignment]
10824+
setattr(cls, "mean", mean)
1084210825

1084310826
@doc(
1084410827
_num_doc,
@@ -10853,8 +10836,7 @@ def mean(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1085310836
def skew(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1085410837
return NDFrame.skew(self, axis, skipna, level, numeric_only, **kwargs)
1085510838

10856-
# error: Cannot assign to a method
10857-
cls.skew = skew # type: ignore[assignment]
10839+
setattr(cls, "skew", skew)
1085810840

1085910841
@doc(
1086010842
_num_doc,
@@ -10872,8 +10854,7 @@ def skew(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1087210854
def kurt(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1087310855
return NDFrame.kurt(self, axis, skipna, level, numeric_only, **kwargs)
1087410856

10875-
# error: Cannot assign to a method
10876-
cls.kurt = kurt # type: ignore[assignment]
10857+
setattr(cls, "kurt", kurt)
1087710858
cls.kurtosis = kurt
1087810859

1087910860
@doc(
@@ -10891,8 +10872,7 @@ def median(
1089110872
):
1089210873
return NDFrame.median(self, axis, skipna, level, numeric_only, **kwargs)
1089310874

10894-
# error: Cannot assign to a method
10895-
cls.median = median # type: ignore[assignment]
10875+
setattr(cls, "median", median)
1089610876

1089710877
@doc(
1089810878
_num_doc,
@@ -10909,8 +10889,7 @@ def median(
1090910889
def max(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1091010890
return NDFrame.max(self, axis, skipna, level, numeric_only, **kwargs)
1091110891

10912-
# error: Cannot assign to a method
10913-
cls.max = max # type: ignore[assignment]
10892+
setattr(cls, "max", max)
1091410893

1091510894
@doc(
1091610895
_num_doc,
@@ -10927,8 +10906,7 @@ def max(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1092710906
def min(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
1092810907
return NDFrame.min(self, axis, skipna, level, numeric_only, **kwargs)
1092910908

10930-
# error: Cannot assign to a method
10931-
cls.min = min # type: ignore[assignment]
10909+
setattr(cls, "min", min)
1093210910

1093310911
@final
1093410912
@doc(Rolling)

0 commit comments

Comments
 (0)