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 AlexWaygood
Recipients AlexWaygood, berker.peksag, corona10, randolf.scholz, rhettinger, serhiy.storchaka, terry.reedy, wim.glenn
Date 2021-10-11.22:43:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633992194.85.0.611012456713.issue45356@roundup.psfhosted.org>
In-reply-to
Content
Some thoughts from me, as an unqualified but interested party:

Like Randolph, I very much like having class properties in the language, and have used them in several projects since their introduction in 3.9. I find they're especially useful with Enums. However, while the bug in doctest, for example, is relatively trivial to fix (see my PR in #44904), it seems to me plausible that bugs might crop up in other standard library modules as well. As such, leaving class properties in the language might mean that several more bugfixes relating to this feature would have to be made in the future. So, I can see the argument for removing them.

It seems to me that Randolph's idea of changing `classmethod` from a class into a function would break a lot of existing code. As an alternative, one small adjustment that could be made would be to special-case `isinstance()` when it comes to class properties. In pure Python, you could achieve this like this:

```
oldproperty = property

class propertymeta(type):
    def __instancecheck__(cls, obj):
        return super().__instancecheck__(obj) or (
            isinstance(obj, classmethod)
            and super().__instancecheck__(obj.__func__)
            )


class property(oldproperty, metaclass=propertymeta): pass
```

This would at least mean that `isinstance(classmethod(property(lambda cls: 42)), property)` and `isinstance(classmethod(property(lambda cls: 42)), classmethod)` would both evaluate to `True`. This would be a bit of a lie (an instance of `classmethod` isn't an instance of `property`), but would at least warn the caller that the object they were dealing with had some propertylike qualities to it.

Note that this change wouldn't fix the bugs in abc and doctest, nor does it fix the issue with class-property setter logic that Randolph identified.

With regards to the point that `@staticmethod` cannot be stacked on top of `@property`: it strikes me that this feature isn't really needed. You can achieve the same effect just by stacking `@classmethod` on top of `@property` and not using the `cls` parameter.
History
Date User Action Args
2021-10-11 22:43:14AlexWaygoodsetrecipients: + AlexWaygood, rhettinger, terry.reedy, berker.peksag, serhiy.storchaka, wim.glenn, corona10, randolf.scholz
2021-10-11 22:43:14AlexWaygoodsetmessageid: <1633992194.85.0.611012456713.issue45356@roundup.psfhosted.org>
2021-10-11 22:43:14AlexWaygoodlinkissue45356 messages
2021-10-11 22:43:14AlexWaygoodcreate