Skip to content

Preserve list structure when setting a list index - #199

Open
Sanjays2402 wants to merge 1 commit into
beetbox:mainfrom
Sanjays2402:fix/set-list-index-preserves-list
Open

Preserve list structure when setting a list index#199
Sanjays2402 wants to merge 1 commit into
beetbox:mainfrom
Sanjays2402:fix/set-list-index-preserves-list

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #169

Subview.set overlaid {key: value} on the parent, so setting through an integer index replaced the containing list with an integer-keyed mapping: config["stages"][0]["name"].set(x) turned stages into {0: {"name": x}}. It now rebuilds the list with only that index replaced when the parent resolves to a list, and __setitem__ routes through the subview so item assignment takes the same path.

Regression tests added for the flat and nested cases; they fail on the previous behaviour. Full suite: 295 passed, 3 skipped.

Setting a value through an integer subview overlaid a dict of
{index: value} on top of the parent, so a list source was replaced by an
integer-keyed mapping: config["stages"][0]["name"].set(x) turned the
whole "stages" list into {0: {"name": x}}.

Subview.set now detects an integer key whose parent resolves to a list
and rebuilds that list with only the target index replaced.
ConfigView.__setitem__ routes through the subview so item assignment
takes the same path.

Adds regression tests for both the flat and nested list cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamically updating a view with list content fails.

1 participant