We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1387c5f commit e74633bCopy full SHA for e74633b
pandas/_libs/properties.pyx
@@ -37,6 +37,9 @@ cdef class CachedProperty(object):
37
PyDict_SetItem(cache, self.name, val)
38
return val
39
40
+ def __set__(self, obj, value):
41
+ raise AttributeError("Can't set attribute")
42
+
43
44
cache_readonly = CachedProperty
45
pandas/tests/indexes/test_base.py
@@ -2056,6 +2056,11 @@ def test_iadd_preserves_name(self):
2056
ser.index -= 1
2057
assert ser.index.name == "foo"
2058
2059
+ def test_cached_properties_not_settable(self):
2060
+ idx = pd.Index([1, 2, 3])
2061
+ with tm.assert_raises_regex(AttributeError, "Can't set attribute"):
2062
+ idx.is_unique = False
2063
2064
2065
class TestMixedIntIndex(Base):
2066
# Mostly the tests from common.py for which the results differ
0 commit comments