Skip to content

Commit 5536d0f

Browse files
committed
Try to fix coverage/types
1 parent 55ab8fe commit 5536d0f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

frozenlist/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __reduce__(self):
106106
)
107107

108108

109-
def _reconstruct_pyfrozenlist(items, frozen):
109+
def _reconstruct_pyfrozenlist(items: list[Any], frozen: bool) -> "PyFrozenList":
110110
"""Helper function to reconstruct the pure Python FrozenList during unpickling.
111111
This function is needed since otherwise the class renaming confuses pickle."""
112112
fl = PyFrozenList(items)

tests/test_frozenlist.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,20 @@ def test_deepcopy_frozen(self) -> None:
274274
with pytest.raises(RuntimeError):
275275
copied.append(4)
276276

277+
def test_deepcopy_frozen_circular(self) -> None:
278+
orig = self.FrozenList([1, 2])
279+
orig.append(orig) # Create circular reference
280+
orig.freeze()
281+
copied = deepcopy(orig)
282+
assert copied[0] == 1
283+
assert copied[1] == 2
284+
assert len(copied[2]) == 3
285+
assert copied[2][0] == 1
286+
assert copied[2][1] == 2
287+
assert len(copied[2][2]) == 3
288+
# ... and so on. Testing equality when a structure includes itself is tough.
289+
assert orig.frozen
290+
277291
def test_deepcopy_nested(self) -> None:
278292
inner = self.FrozenList([1, 2])
279293
orig = self.FrozenList([inner, 3])

0 commit comments

Comments
 (0)