<div dir="auto">I don't care about the deprecation either way. But can we fix the individual decorators so both orders work? Even if it requires a special case in the code, it seems worthwhile to remove a subtle user-visible footgun.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 15, 2019, 12:39 Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In issue 11610* abstractclassmethod and abstractstaticmethod were deprecated, apparently because they were redundant with the new technique of calling `classmethod` or `staticmethod` followed by a call to `abstractmethod`.  To put it in code:<br>
<br>
# deprecated<br>
<br>
class Foo(ABC):<br>
<br>
     @abstractclassmethod<br>
     def foo_happens(cls):<br>
         # do some fooey stuff<br>
<br>
# the new(er) way<br>
<br>
class Foo(ABC):<br>
<br>
     @classmethod<br>
     @abstractmethod<br>
     def foo_happens(cls):<br>
         # do some fooey stuff<br>
<br>
<br>
I would like to remove the deprecated status of `abstractclassmethod` and `abstractstaticmethod` mainly because:<br>
<br>
- using the combined decorator is easy to get right<br>
   (@abstractmethod followed by @classmethod doesn't work)<br>
<br>
- getting the order wrong can be hard to spot and fix<br>
<br>
Obviously, decorator order matters for many, if not most, decorators out there -- so why should these two be any different?  Because 'abstract', 'class', and 'static' are adjectives -- they're describing the method, rather than changing it**; to use an example, what is the difference between "hot, dry sand" and "dry, hot sand"?  The sand is just as dry and just as hot either way.  In a debugging session looking at:<br>
<br>
    @abstractmethod<br>
    @classmethod<br>
    def some_func(self, this, that, the_other):<br>
         # many<br>
         # many<br>
         ...<br>
         ...<br>
         ...<br>
         # many<br>
         # lines<br>
         # of<br>
         # code<br>
<br>
Not noticing that the two decorators are in reverse order would be very easy to do.<br>
<br>
Because order matters here, but cognitively should not, a helper function to make sure it is always done right is a prime candidate to be added to a module -- and, luckily for us, those helper functions already exist!  Unfortunately, they are also deprecated, discouraging their use, when we should be encouraging their use.<br>
<br>
What are the reasons to /not/ remove the deprecation?<br>
<br>
--<br>
~Ethan~<br>
<br>
<br>
<br>
* <a href="https://bugs.python.org/issue11610" rel="noreferrer noreferrer" target="_blank">https://bugs.python.org/issue11610</a><br>
<br>
** I realize that abstractmethod does actually change the function, but that's an implementation detail.<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank" rel="noreferrer">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/njs%40pobox.com" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/njs%40pobox.com</a><br>
</blockquote></div>