This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients carljm, levkivskyi, methane, mwilbz, serhiy.storchaka, sir-sigurd, vstinner
Date 2018-11-21.06:24:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1542781475.82.0.788709270274.issue34995@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-11-21 06:24:35methanesetrecipients: + methane, vstinner, carljm, serhiy.storchaka, levkivskyi, sir-sigurd, mwilbz
2018-11-21 06:24:35methanesetmessageid: <1542781475.82.0.788709270274.issue34995@psf.upfronthosting.co.za>
2018-11-21 06:24:35methanelinkissue34995 messages
2018-11-21 06:24:34methanecreate