Repository navigation
Treat dict and list subclasses as groupings in flatten_grouping - #4240
Open
shaurya703 wants to merge 2 commits into
Open
shaurya703 wants to merge 2 commits into
shaurya703 wants to merge 2 commits into
Conversation
flatten_grouping compared exact types (type(x) is dict) since plotly#3303, so an OrderedDict or other dict subclass was returned as one scalar value. The rest of the module uses isinstance, so grouping_len and flatten_grouping disagreed on the same grouping, and a callback registered with an OrderedDict output or inputs failed with "Invalid value provided where an Output dependency object was expected".
|
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 #3303 (3.1.0),
flatten_groupingcheckstype(sch) is dictandtype(sch) is tuple or type(sch) is listinstead ofisinstance. A dict subclass such asOrderedDictis no longer treated as a grouping. It comes back as one scalar value:grouping_len,validate_grouping,make_grouping_by_indexandmap_groupingin the same module still useisinstance, so they disagree withflatten_groupingabout the same value. In a callback this shows up as a misleading error:The same callback works today with a plain
dict. It also works with anOrderedDictifdash/_grouping.pyis put back to its version from before #3303: both new tests below pass against that version.Fix: go back to
isinstance(sch, (tuple, list))andisinstance(sch, dict)and keep the rest of the stack-based loop from #3303 as it is.Contributor Checklist
dev(fix)test_flatten_dict_subclassintests/unit/library/test_grouping.pytest_callback_output_and_input_dict_subclassintests/unit/library/test_grouped_callbacks.py, which registers and calls a callback withOrderedDictoutput and inputsBoth new tests fail on
devand pass with the change.optionals
CHANGELOG.mdChecks run locally:
pytest tests/unit(777 passed, 7 skipped),black --checkandflake8ondashandtests(clean), andpylint dash setup.py --rcfile=.pylintrc, which reports only existingnot-callablewarnings indash/testing/browser.pyanddiskcache_manager.py. I ran these with component bundles taken from the 4.5.2 wheel instead of annpm run build, and I did not run the renderer or integration tests. The change is Python-only.