From f3d7db25a04c80a94980d6d960deab96b62976b8 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Thu, 24 Jun 2021 13:12:55 +0300 Subject: [PATCH 1/5] Clarify the order of a stacked `abstractmethod` --- Lib/abc.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Lib/abc.py b/Lib/abc.py index 276ef9a2cd4850..3c73642ded4c6d 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -28,7 +28,13 @@ def my_abstract_method(self, ...): class abstractclassmethod(classmethod): """A decorator indicating abstract classmethods. - Deprecated, use 'classmethod' with 'abstractmethod' instead. + Deprecated, instead use `classmethod` on top of `abstractmethod`: + + @classmethod + @abstractmethod + def your_function(cls): + ... + """ __isabstractmethod__ = True @@ -41,7 +47,13 @@ def __init__(self, callable): class abstractstaticmethod(staticmethod): """A decorator indicating abstract staticmethods. - Deprecated, use 'staticmethod' with 'abstractmethod' instead. + Deprecated, instead use `staticmethod` on top of `abstractmethod`: + + @staticmethod + @abstractmethod + def your_function(): + ... + """ __isabstractmethod__ = True @@ -54,7 +66,13 @@ def __init__(self, callable): class abstractproperty(property): """A decorator indicating abstract properties. - Deprecated, use 'property' with 'abstractmethod' instead. + Deprecated, instead use `property` on top of `abstractmethod`: + + @property + @abstractmethod + def your_function(self): + ... + """ __isabstractmethod__ = True From 445e9d5a94c4f10c308a85fe47df3999f908e671 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Sun, 27 Jun 2021 19:34:39 +0300 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Tal Einat <532281+taleinat@users.noreply.github.com> --- Lib/abc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/abc.py b/Lib/abc.py index 3c73642ded4c6d..3fe0376bbd92e3 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -28,11 +28,11 @@ def my_abstract_method(self, ...): class abstractclassmethod(classmethod): """A decorator indicating abstract classmethods. - Deprecated, instead use `classmethod` on top of `abstractmethod`: + Deprecated, use 'classmethod' with 'abstractmethod' instead: @classmethod @abstractmethod - def your_function(cls): + def my_abstract_classmethod(cls, ...): ... """ @@ -51,7 +51,7 @@ class abstractstaticmethod(staticmethod): @staticmethod @abstractmethod - def your_function(): + def my_abstract_staticmethod(...): ... """ @@ -70,7 +70,7 @@ class abstractproperty(property): @property @abstractmethod - def your_function(self): + def my_abstract_property(self): ... """ From eb06fd15153cfadd57dcd3353f0cc437c8592866 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Sun, 27 Jun 2021 19:35:42 +0300 Subject: [PATCH 3/5] Apply more suggestions from code review --- Lib/abc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/abc.py b/Lib/abc.py index 3fe0376bbd92e3..f137d472798c6d 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -47,7 +47,7 @@ def __init__(self, callable): class abstractstaticmethod(staticmethod): """A decorator indicating abstract staticmethods. - Deprecated, instead use `staticmethod` on top of `abstractmethod`: + Deprecated, use 'staticmethod' with 'abstractmethod' instead: @staticmethod @abstractmethod @@ -66,7 +66,7 @@ def __init__(self, callable): class abstractproperty(property): """A decorator indicating abstract properties. - Deprecated, instead use `property` on top of `abstractmethod`: + Deprecated, use 'property' with 'abstractmethod' instead: @property @abstractmethod From db5d3882eaac24c298fc41af5bb22e1a4f474c79 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Sun, 27 Jun 2021 19:37:50 +0300 Subject: [PATCH 4/5] Update Lib/abc.py Co-authored-by: Tal Einat <532281+taleinat@users.noreply.github.com> --- Lib/abc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/abc.py b/Lib/abc.py index f137d472798c6d..4f932e6fdcb4ff 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -30,6 +30,7 @@ class abstractclassmethod(classmethod): Deprecated, use 'classmethod' with 'abstractmethod' instead: + class C(ABC): @classmethod @abstractmethod def my_abstract_classmethod(cls, ...): From 56dda1d740695281853acd12ff6eb23e5398e761 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Sun, 27 Jun 2021 19:38:18 +0300 Subject: [PATCH 5/5] Apply even more suggestions from code review --- Lib/abc.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Lib/abc.py b/Lib/abc.py index 4f932e6fdcb4ff..3c552cebb4226c 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -30,11 +30,11 @@ class abstractclassmethod(classmethod): Deprecated, use 'classmethod' with 'abstractmethod' instead: - class C(ABC): - @classmethod - @abstractmethod - def my_abstract_classmethod(cls, ...): - ... + class C(ABC): + @classmethod + @abstractmethod + def my_abstract_classmethod(cls, ...): + ... """ @@ -50,10 +50,11 @@ class abstractstaticmethod(staticmethod): Deprecated, use 'staticmethod' with 'abstractmethod' instead: - @staticmethod - @abstractmethod - def my_abstract_staticmethod(...): - ... + class C(ABC): + @staticmethod + @abstractmethod + def my_abstract_staticmethod(...): + ... """ @@ -69,10 +70,11 @@ class abstractproperty(property): Deprecated, use 'property' with 'abstractmethod' instead: - @property - @abstractmethod - def my_abstract_property(self): - ... + class C(ABC): + @property + @abstractmethod + def my_abstract_property(self): + ... """