[issue34995] functools.cached_property does not maintain the wrapped method's __isabstractmethod__

Matt Wilber report at bugs.python.org
Wed Oct 17 11:50:39 EDT 2018


Matt Wilber <mattwilber94 at gmail.com> added the comment:

I agree, a comment can serve the same purpose. But for the same reasons it's useful to express typing hints in Python with real syntax, and the reasons it's useful to have the abc module in the first place, I think it is useful to be able to annotate an abstract method with @cachedproperty.

The purpose of this change is not to add code developers would try to use at runtime, it is to allow developers to communicate their intentions to static code analysis tools and to other developers, using standard decorators from builtins that do not break one another. Indeed, abstract methods should not be executed (on purpose), but Python still supports abstract methods to protect developers who want to explicitly label their code as "do not execute".

Therefore, please do not think of this change as something someone would try to execute. It is for hinting functionality, and it is to protect developers who would decorate a method with @cached_property and @abstractmethod and find that abc's functionality was unexpectedly broken.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34995>
_______________________________________


More information about the Python-bugs-list mailing list