From b82c810cd12b9cb88769934cedf6147caed14abb Mon Sep 17 00:00:00 2001 From: yadav-sachin Date: Tue, 5 Apr 2022 01:06:12 +0530 Subject: [PATCH 1/7] readd changes in frame, series without actual implementations --- pandas/core/frame.py | 11 +++++++++++ pandas/core/series.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 6d4deb79b4898..618c9a36eb3f5 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8942,6 +8942,17 @@ def aggregate(self, func=None, axis: Axis = 0, *args, **kwargs): agg = aggregate + @doc(NDFrame.any, **_shared_doc_kwargs) + def any( + self: DataFrame, + axis: Axis = 0, + bool_only: bool | None = None, + skipna: bool = True, + level: Level | None = None, + **kwargs, + ) -> DataFrame | Series: + ... + @doc( _shared_docs["transform"], klass=_shared_doc_kwargs["klass"], diff --git a/pandas/core/series.py b/pandas/core/series.py index 1d3509cac0edd..1cc15d1c2c636 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4397,6 +4397,17 @@ def aggregate(self, func=None, axis=0, *args, **kwargs): agg = aggregate + @doc(NDFrame.any, **_shared_doc_kwargs) + def any( + self: Series, + axis: Axis = 0, + bool_only: bool | None = None, + skipna: bool = True, + level: Level | None = None, + **kwargs, + ) -> Series | bool: + ... + @doc( _shared_docs["transform"], klass=_shared_doc_kwargs["klass"], From f40bb8c947408c4975495433bc1f5d71f73d98ff Mon Sep 17 00:00:00 2001 From: yadav-sachin Date: Tue, 5 Apr 2022 01:43:07 +0530 Subject: [PATCH 2/7] update return types in generic.py --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 2e65e3139ffa1..d57d4a36cabea 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10517,7 +10517,7 @@ def any( skipna: bool_t = True, level: Level | None = None, **kwargs, - ) -> Series | bool_t: + ) -> DataFrame | Series | bool_t: return self._logical_func( "any", nanops.nanany, axis, bool_only, skipna, level, **kwargs ) From 426d7e778179be114aad1564fc6fbd6d39586f4a Mon Sep 17 00:00:00 2001 From: yadav-sachin Date: Sun, 1 May 2022 16:00:43 +0530 Subject: [PATCH 3/7] add overload defs for level --- pandas/core/frame.py | 25 +++++++++++++++++++++++++ pandas/core/generic.py | 1 + pandas/core/series.py | 25 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 1af6cbe3cfd70..0a5443f49e5bf 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8942,9 +8942,34 @@ def aggregate(self, func=None, axis: Axis = 0, *args, **kwargs): agg = aggregate + @overload + def any( + self: DataFrame, + *, + axis: Axis = ..., + bool_only: bool | None = ..., + skipna: bool = ..., + level: None = ..., + **kwargs, + ) -> Series: + ... + + @overload + def any( + self: DataFrame, + *, + axis: Axis = ..., + bool_only: bool | None = ..., + skipna: bool = ..., + level=Level, + **kwargs, + ) -> DataFrame | Series: + ... + @doc(NDFrame.any, **_shared_doc_kwargs) def any( self: DataFrame, + *, axis: Axis = 0, bool_only: bool | None = None, skipna: bool = True, diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 473435bae48eb..160e0d23c5576 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10512,6 +10512,7 @@ def _logical_func( def any( self, + *, axis: Axis = 0, bool_only: bool_t | None = None, skipna: bool_t = True, diff --git a/pandas/core/series.py b/pandas/core/series.py index 1cc15d1c2c636..99d09a08f66f4 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4397,9 +4397,34 @@ def aggregate(self, func=None, axis=0, *args, **kwargs): agg = aggregate + @overload + def any( + self: Series, + *, + axis: Axis = ..., + bool_only: bool | None = ..., + skipna: bool = ..., + level: None = ..., + **kwargs, + ) -> bool: + ... + + @overload + def any( + self: Series, + *, + axis: Axis = ..., + bool_only: bool | None = ..., + skipna: bool = ..., + level=Level, + **kwargs, + ) -> Series | bool: + ... + @doc(NDFrame.any, **_shared_doc_kwargs) def any( self: Series, + *, axis: Axis = 0, bool_only: bool | None = None, skipna: bool = True, From 0fbd5416277dd6d34d8dfee10f56858ddf695551 Mon Sep 17 00:00:00 2001 From: yadav-sachin Date: Mon, 2 May 2022 15:40:34 +0530 Subject: [PATCH 4/7] remove keyword-args constraint in generic --- pandas/core/generic.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a32e07367e1dc..c615216240d60 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10512,7 +10512,6 @@ def _logical_func( def any( self, - *, axis: Axis = 0, bool_only: bool_t | None = None, skipna: bool_t = True, From c0bc37d9f4e3028c81070f8dc8872fe6ddbcf121 Mon Sep 17 00:00:00 2001 From: yadav-sachin Date: Fri, 6 May 2022 19:58:46 +0530 Subject: [PATCH 5/7] fix typo in overload defs --- pandas/core/frame.py | 2 +- pandas/core/series.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a516de7a6e2e7..03a57f7a0092a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9007,7 +9007,7 @@ def any( axis: Axis = ..., bool_only: bool | None = ..., skipna: bool = ..., - level=Level, + level: Level, **kwargs, ) -> DataFrame | Series: ... diff --git a/pandas/core/series.py b/pandas/core/series.py index 99d09a08f66f4..3a8e25cda8119 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4416,7 +4416,7 @@ def any( axis: Axis = ..., bool_only: bool | None = ..., skipna: bool = ..., - level=Level, + level: Level, **kwargs, ) -> Series | bool: ... From 0f7578219367caf6d747951219c879c40240d8fa Mon Sep 17 00:00:00 2001 From: yadav-sachin Date: Sat, 7 May 2022 03:17:17 +0530 Subject: [PATCH 6/7] add error comments above func defs --- pandas/core/frame.py | 2 ++ pandas/core/series.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 03a57f7a0092a..24a638e7a4cfb 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8988,6 +8988,7 @@ def aggregate(self, func=None, axis: Axis = 0, *args, **kwargs): agg = aggregate + # error: Signature of "any" incompatible with supertype "NDFrame" [override] @overload def any( self: DataFrame, @@ -9012,6 +9013,7 @@ def any( ) -> DataFrame | Series: ... + # error: Signature of "any" incompatible with supertype "NDFrame" [override] @doc(NDFrame.any, **_shared_doc_kwargs) def any( self: DataFrame, diff --git a/pandas/core/series.py b/pandas/core/series.py index 3a8e25cda8119..0dd70bb8f1ccf 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4397,6 +4397,7 @@ def aggregate(self, func=None, axis=0, *args, **kwargs): agg = aggregate + # error: Signature of "any" incompatible with supertype "NDFrame" [override] @overload def any( self: Series, @@ -4421,6 +4422,7 @@ def any( ) -> Series | bool: ... + # error: Signature of "any" incompatible with supertype "NDFrame" [override] @doc(NDFrame.any, **_shared_doc_kwargs) def any( self: Series, From d27fdc0f2f4b8bcd5d5913564f45271d9c34383d Mon Sep 17 00:00:00 2001 From: yadav-sachin Date: Sat, 7 May 2022 14:30:16 +0530 Subject: [PATCH 7/7] remove self annotations, * in implement, add type ignore --- pandas/core/frame.py | 10 ++++------ pandas/core/series.py | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 24a638e7a4cfb..bc190257a1cdd 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8989,9 +8989,9 @@ def aggregate(self, func=None, axis: Axis = 0, *args, **kwargs): agg = aggregate # error: Signature of "any" incompatible with supertype "NDFrame" [override] - @overload + @overload # type: ignore[override] def any( - self: DataFrame, + self, *, axis: Axis = ..., bool_only: bool | None = ..., @@ -9003,7 +9003,7 @@ def any( @overload def any( - self: DataFrame, + self, *, axis: Axis = ..., bool_only: bool | None = ..., @@ -9013,11 +9013,9 @@ def any( ) -> DataFrame | Series: ... - # error: Signature of "any" incompatible with supertype "NDFrame" [override] @doc(NDFrame.any, **_shared_doc_kwargs) def any( - self: DataFrame, - *, + self, axis: Axis = 0, bool_only: bool | None = None, skipna: bool = True, diff --git a/pandas/core/series.py b/pandas/core/series.py index 0dd70bb8f1ccf..b740bac78b263 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4398,9 +4398,9 @@ def aggregate(self, func=None, axis=0, *args, **kwargs): agg = aggregate # error: Signature of "any" incompatible with supertype "NDFrame" [override] - @overload + @overload # type: ignore[override] def any( - self: Series, + self, *, axis: Axis = ..., bool_only: bool | None = ..., @@ -4412,7 +4412,7 @@ def any( @overload def any( - self: Series, + self, *, axis: Axis = ..., bool_only: bool | None = ..., @@ -4422,11 +4422,9 @@ def any( ) -> Series | bool: ... - # error: Signature of "any" incompatible with supertype "NDFrame" [override] @doc(NDFrame.any, **_shared_doc_kwargs) def any( - self: Series, - *, + self, axis: Axis = 0, bool_only: bool | None = None, skipna: bool = True,