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 randolf.scholz
Recipients AlexWaygood, corona10, randolf.scholz, terry.reedy, wim.glenn
Date 2021-10-10.09:57:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633859872.79.0.769974352526.issue45356@roundup.psfhosted.org>
In-reply-to
Content
@Terry I think the problem boils down to the fact that `@classmethod @property` decorated methods end up not being real properties.

Calling `MyBaseClass.__dict__` reveals:

```python
mappingproxy({'__module__': '__main__',
              'expensive_class_property': <classmethod at 0x7f893e95dd60>,
              'expensive_instance_property': <property at 0x7f893e8a5860>,
              '__dict__': <attribute '__dict__' of 'MyBaseClass' objects>,
              '__weakref__': <attribute '__weakref__' of 'MyBaseClass' objects>,
              '__doc__': None,
              '__abstractmethods__': frozenset(),
              '_abc_impl': <_abc._abc_data at 0x7f893fb98740>})
```

Two main issues:

1. Any analytics or documentation tool that has special treatment for properties may not identify 'expensive_class_property' as a property if they simply check via `isinstance(func, property)`. Of course, this could be fixed by the tool-makers by doing a conditional check:

```python
isinstance(func, property) or (`isinstance(func, classmethod)` and `isinstance(func.__func__, property)`
```

2. `expensive_class_property` does not implement `getter`, `setter`, `deleter`. This seems to be the real dealbreaker, for example, if we do

```python
MyBaseClass.expensive_class_property = 2
MyBaseClass().expensive_instance_property = 2
```

Then the first line erroneously executes, such that MyBaseClass.__dict__['expensive_class_property'] is now `int` instead of `classmethod`, while the second line correctly raises `AttributeError: can't set attribute` since the setter method is not implemented.
History
Date User Action Args
2021-10-10 09:57:52randolf.scholzsetrecipients: + randolf.scholz, terry.reedy, wim.glenn, corona10, AlexWaygood
2021-10-10 09:57:52randolf.scholzsetmessageid: <1633859872.79.0.769974352526.issue45356@roundup.psfhosted.org>
2021-10-10 09:57:52randolf.scholzlinkissue45356 messages
2021-10-10 09:57:52randolf.scholzcreate