Skip to content

Implement deepcopy support#662

Merged
bdraco merged 3 commits intomasterfrom
deepcopy
Jun 9, 2025
Merged

Implement deepcopy support#662
bdraco merged 3 commits intomasterfrom
deepcopy

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented Jun 9, 2025

What do these changes do?

Implements deepcopy support for FrozenList by adding a __deepcopy__ method. This allows FrozenList objects to be deep copied using Python's copy.deepcopy() function, which was previously failing with a TypeError.

Are there changes in behavior for the user?

Users can now use copy.deepcopy() on FrozenList objects without errors. The deepcopy operation:

  • Creates a complete copy of the FrozenList and all its contents
  • Preserves the frozen state of the original list
  • Correctly handles circular references and nested structures
  • Maintains shared references within the copied structure

Related issue number

Closes #659

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modifications, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep the list in alphabetical order, the file is sorted by name.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@bdraco bdraco marked this pull request as ready for review June 9, 2025 22:06
@bdraco bdraco enabled auto-merge (squash) June 9, 2025 22:08
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.84%. Comparing base (8c9d264) to head (bca9f61).
⚠️ Report is 23 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #662      +/-   ##
==========================================
+ Coverage   94.14%   94.84%   +0.70%     
==========================================
  Files          10       10              
  Lines         632      718      +86     
  Branches       46       48       +2     
==========================================
+ Hits          595      681      +86     
  Misses         13       13              
  Partials       24       24              
Flag Coverage Δ
CI-GHA 94.70% <100.00%> (+0.72%) ⬆️
MyPy 64.75% <11.62%> (-7.95%) ⬇️
OS-Linux 99.70% <100.00%> (+0.10%) ⬆️
OS-Windows 99.70% <100.00%> (+0.10%) ⬆️
OS-macOS 99.40% <100.00%> (+0.20%) ⬆️
Py-3.10.11 99.70% <100.00%> (+0.10%) ⬆️
Py-3.10.17 99.70% <100.00%> (+0.10%) ⬆️
Py-3.11.12 99.70% <100.00%> (+0.10%) ⬆️
Py-3.11.9 99.70% <100.00%> (+0.10%) ⬆️
Py-3.12.10 99.70% <100.00%> (+0.10%) ⬆️
Py-3.13.3 99.70% <100.00%> (+0.10%) ⬆️
Py-3.13.4t 99.70% <100.00%> (+0.10%) ⬆️
Py-3.9.13 99.70% <100.00%> (+0.10%) ⬆️
Py-3.9.22 99.70% <100.00%> (+0.10%) ⬆️
Py-pypy7.3.16 98.81% <100.00%> (+0.40%) ⬆️
Py-pypy7.3.19 98.81% <100.00%> (+0.40%) ⬆️
VM-macos-latest 99.40% <100.00%> (+0.20%) ⬆️
VM-ubuntu-latest 99.70% <100.00%> (+0.10%) ⬆️
VM-windows-latest 99.70% <100.00%> (+0.10%) ⬆️
pytest 99.70% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco bdraco merged commit 6104de5 into master Jun 9, 2025
44 of 47 checks passed
@bdraco bdraco deleted the deepcopy branch June 9, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.6.2: frozenlist does not work with deepcopy

1 participant