INADA Naoki <songofaca...@gmail.com> added the comment:

My personal opinion is: support abstractmethod only when the descriptor is 
useful for define interface with ABC.

In case of cached_property, it's not.  It is just a property as interface 
level.  Caching is just an implementation.

In case of update_wrapper, it's too generic.  A decorated function may be used 
while define interface, but it's a rare case.  So no need to support it.

In case of singledispatch, I think it is not used in ABC, like cached_property. 
 But it has shipped in Python already.  We shouldn't remove it easily.

In case of partialmethod... it's considerable. I don't use ABC much, and I 
never use partialmethod.  So this example is very artificial.

class MyABC(abc.ABC):
    @abstractmethod
    def set_foo(self, v):
        pass
    reset_foo = partialmethod(set_foo, None)

When they subclass of MyABC, they need to override both of `set_foo` and 
`reset_foo`.  Otherwise, reset_foo is bound to MyABC.set_foo, not subclass' one.
So __isabstractmethod__ support in partialmethod is not just a "commet as a 
code".

On the other hand, this example can be written as:

class MyABC(abc.ABC):
    @abstractmethod
    def set_foo(self, v):
        pass
    @abstractmethod
    def reset_foo(self):
        pass

Or it can use lazy binding too:

class MyABC(abc.ABC):
    @abstractmethod
    def set_foo(self, v):
        pass

    # No need to override if default implementation is OK
    def reset_foo(self):
        self.set_foo(None)

I am not sure __isabstractmethod__ support in partialmethod is really useful.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34995>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to