Repository navigation
fix: return a writable copy from get_rule_config - #59
Merged
Merged
Conversation
TextDB.on() results are shared with the database cache and read-only since dbetto 1.3.5, so scripts could not edit their rule config (or, through unguarded methods, silently changed the shared copy). Deep-copy the small rule config so every script owns it. Assisted-by: Generative AI
1 task
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.
Since dbetto 1.3.5 (gipert/dbetto#48),
TextDB.on()returns objects that share their contents with the database cache, flagged read-only. So a script can't edit its own rule config:config[...] = ...raisesTypeError. And the dict/list methods dbetto doesn't guard (pop,setdefault,append, …) silently change the shared copy.build_log'ssetdefaultpath is one latent example.get_rule_confignow returns acopy.deepcopyof the rule config. It's small and resolved once per script, so each script owns its config regardless of dbetto's read-only rules.Validation. The extended
test_get_rule_configedits the returned config and checks that a second call is unaffected. It fails onmain(TypeError: this AttrsDict is read-only) and passes here.pytest -n 5gives 83 passed with dbetto 1.4.0 and with the read-only fix in gipert/dbetto. legend-dataflowpytest -n 5gives 128 passed with this branch.pre-commit run -apasses.🤖 Generated with Claude Code