CellCollection.cells exposes a mutable cached list, causing inconsistent collection behavior
Describe the bug The CellCollection.cells property uses @cached_property and returns a mutable list of the collection's cells.
Because the list is cached, modifying the returned list affects subsequent accesses to collection.cells, even though the underlying collection (_cells) remains unchanged.
Expected behavior Modifying the list returned by collection.cells should not modify the result of subsequent accesses or affect operations on the collection.
To Reproduce
cell1 = Cell((0, 0))
cell2 = Cell((0, 1))
collection = CellCollection([cell1, cell2])
cells = collection.cells
cells.clear()
print(len(collection)) # 2
print(len(collection.cells)) # 0
Look at the docstring for CellCollection: "An immutable collection of cells". So, I don't see a bug here.
I think I begin to understand the claimed bug. Closing it might be premature. However, the proper fix would be to to let the property return a tuple rather than a list. Since this is a bug fix, the fact that it might be break stuff does not matter for semver.