Skip to content

Fix node_generator skipping dicts nested inside lists - #5912

Open
adityajai119 wants to merge 1 commit into
plotly:mainfrom
adityajai119:fix-node-generator-list-traversal
Open

adityajai119 wants to merge 1 commit into
plotly:mainfrom
adityajai119:fix-node-generator-list-traversal

Conversation

@adityajai119

Copy link
Copy Markdown

plotly.utils.node_generator only descended into dict values, so it never yielded nested dicts stored inside lists (for example traces in a figure's data array). Its docstring states that paths may contain list indices, and get_by_path supports them, so list-nested dicts were silently skipped by consumers such as the figure-comparison test helper.

This makes node_generator walk dicts and lists/tuples generically, yielding every dict with the correct path.

Tests: added test_node_generator_descends_into_lists; tests/test_core/test_utils/test_utils.py (5 passed) and tests/test_optional/test_utils/test_utils.py (25 passed). ruff check and ruff format --check pass on the touched files. Changelog entry added.

@atishay-kasliwal atishay-kasliwal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node_generator on a dict with dicts inside lists, nested lists and tuples now yields ('l', 0), ('l', 0, 'x'), ('l', 2, 0) and ('t', 0); master stopped at ('a',). Top-level dict paths are unchanged.

This branch has not been deployed

No deployments
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.

2 participants