Repository navigation
feat(plugin): add realization and compare to the Python compat layer - #2592
Merged
Merged
Conversation
Beancount's own leafonly and noduplicates import beancount.core.realization and beancount.core.compare, which the compat layer lacked, so both stopped with an ImportError. Both modules are now ported from beancount 3: realization's account tree (realize with compute_balance=False, iter_children, get, get_or_create, contains, postings_by_account, RealAccount) and compare's stable entry hashes (hash_entry, hash_entries, compare_entries, includes_entries, excludes_entries). realize with balances needs beancount.core.inventory and raises NotImplementedError saying so. Closes #2540 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Member
Author
Review loop
The loop converged at round 1. The required checks are green on 72f5323. |
…ization-compare # Conflicts: # CHANGELOG.md
robcohen
added a commit
that referenced
this pull request
Oct 11, 2026
…rance-rounding CHANGELOG: main's file plus this PR's entries. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
This was referenced Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The Python compat layer now provides two more beancount modules, ported from beancount 3:
beancount.core.realization:RealAccount(a dict of child components withaccount,txn_postings,balance),realize(entries, min_accounts=None, compute_balance=...),iter_children(real, leaf_only=False),get,get_or_create,containsandpostings_by_account.postings_by_accountfollows beancount: postings asTxnPosting, andopen,close,balance,note,document,pad(both accounts) andcustomaccount values as entries.beancount.core.compare:CompareError,stable_hash_namedtuple,hash_entry,hash_entries(duplicate prices allowed, as in beancount),compare_entries,includes_entries,excludes_entries.realizewith balances (compute_balance=True, its default) needsbeancount.core.inventory, which the layer does not have. It raisesNotImplementedErrorsaying to passcompute_balance=False(asleafonlydoes), rather than returning a tree without balances.Why
Beancount's own
leafonlyandnoduplicatesimport these modules and stopped withcannot import name 'realization' from 'beancount.core'.How tested
New conformance case
python_compat_realization_and_compare:leafonlyis (realize +iter_children+getters.get_account_open_close) reportsledger.beancount:3:1: ... Non-leaf account 'Assets:Bank' has postings on itand exercisesget,containsanditer_children(leaf_only=True);noduplicates-style plugin flags a duplicated transaction once, at the copy's line, and checksincludes_entriesboth ways;realize(entries)gives theNotImplementedError.It fails without the change (the import fails).
Beancount 3's actual
leafonly.pyandnoduplicates.py, copied from the installed package and run under this build asplugin "leafonly.py"/"noduplicates.py", report what bean-check reports. That includes beancount'sleafonlyreporting a parent named only by anoteorcustom. These files are not vendored: beancount is GPLv2, this repo is GPL-3.0-only.cargo test -p rustledger-plugin --all-featuresand-p rustledger --all-features(withRLEDGER_REQUIRE_*) pass. clippy (workspace, all features) is clean, and so are fmt andcargo doc -D warnings. Release-config clippy has only thewasm_plugins_dirdead-code error, which main already has; the docs: release binaries do not include plugin runtimes #2541 PR fixes it.Closes #2540
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr