Add default fallback for missing keys#107
Open
sachinsachdeva wants to merge 2 commits into
Open
Conversation
Author
|
@drgrib take a look when you get a chance |
Collaborator
|
Thank you for your PR. I'll try to have a closer look this week. Unfortunately time is pretty limited in this crazy time. |
FelixSchwarz
requested changes
Jun 14, 2026
FelixSchwarz
left a comment
Collaborator
There was a problem hiding this comment.
Thank you very much - solid PR which needs just a few changes.
Collaborator
|
Oh, and if you rebase to/merge in the latest master branch, you should also get github actions running again. |
2967e03 to
8a412af
Compare
- Raise ValueError when _default is provided with _dynamic=False instead of silently overriding _dynamic - Nest the _default check inside the existing "k not in self._map" branch in __getitem__ - Preserve _default through copy()/deepcopy() - Add tests for the _dynamic=False error, copy, and deepcopy; reorder the missing-key assertions to check setup before behavior Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
7b967f1 to
2c76767
Compare
Author
|
@FelixSchwarz I think I got all your comments. |
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.
Fixes #74.
This adds an opt-in
_defaultconstructor argument for callers who want missing attributes to return a fallback value instead of autovivifying an emptyDotMap. Existing behavior remains unchanged unless_defaultis provided.Example:
Tests: