default_box_create_on_get=False should still create keys on assigment
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Description
As reported before in https://github.com/cdgriffith/Box/issues/164#issuecomment-1359179014
The current behavior of `default_box_create_on_get` is not what you would expect and eliminates a large part what makes `default_box` useful in the first place.
In the following case I would still expect `b.foo.bar` to be set to `1`.
```
>>> b = Box(default_box=True, default_box_create_on_get=False)
>>> b.foo.bar
Box({})
>>> b.foo.bar = 1
>>> b.foo.bar
Box({})
>>> b
Box({})
```
Not sure if this is feasible, but a new config option `default_box_create_on_set` could be added to control this behavior.
Contributor guide
Research direction
Start by reproducing the example in the issue with default_box=True and default_box_create_on_get=False, then trace the default_box assignment path. Determine how nested assignment is handled and whether a configuration option is needed; done means b.foo.bar = 1 persists the nested key while reads still avoid creating keys.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100