Skip to content

Fix #636: implement sized items and values views for benedict - #637

Merged
fabiocaccamo merged 4 commits into
fabiocaccamo:mainfrom
Gabrieljr42:fix/636-nested-dict-toml-serialization
Oct 20, 2026
Merged

fabiocaccamo merged 4 commits into
fabiocaccamo:mainfrom
Gabrieljr42:fix/636-nested-dict-toml-serialization

Conversation

@Gabrieljr42

Copy link
Copy Markdown
Contributor

Fixes #636.

Summary

Serializers such as toml-rs inspect len() on mapping.items(), which previously failed with TypeError: object of type 'generator' has no len() because benedict.items() and benedict.values() returned generators.

This PR replaces the generator returns with _BenedictItemsView and _BenedictValuesView inheriting from collections.abc.ItemsView and ValuesView, delegating iteration to BaseDict so mutations continue to be reflected and nested dictionaries are cast dynamically.

…dict

Serializers such as toml-rs inspect len() on mapping.items(), which previously
failed with a TypeError because benedict.items() and benedict.values() returned
generators. Replace generator returns with _BenedictItemsView and _BenedictValuesView
inheriting from collections.abc.ItemsView and ValuesView while delegating to BaseDict
to preserve dynamic mutation reflection and nested dict casting.
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.70%. Comparing base (c4c8a58) to head (ca4b4f3).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #637      +/-   ##
==========================================
+ Coverage   98.69%   98.70%   +0.01%     
==========================================
  Files          65       65              
  Lines        2446     2476      +30     
==========================================
+ Hits         2414     2444      +30     
  Misses         32       32              
Flag Coverage Δ
unittests 98.70% <100.00%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@fabiocaccamo fabiocaccamo added the bug Something isn't working label Oct 20, 2026
@fabiocaccamo fabiocaccamo moved this to In Progress in Open Source Oct 20, 2026
@fabiocaccamo
fabiocaccamo merged commit 8c4b47f into fabiocaccamo:main Oct 20, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Open Source Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Incompatibility with toml-rs

2 participants