Allow arbitrary `Mapping` types when setting properties, rather than only `dict`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Currently, it seems that only dict is allowed when setting properties. It would be better if an arbitrary Mapping type were allowed, since that grants the user the flexibility to control properties with alternative data structures such as a ChainMap.
As far as I can tell, this could be done just by changing the validate_coerce() logic to check isinstance(v, Mapping) instead of isinstance(v, dict), e.g. on this line.
Example
This raises a ValueError:
from collections import ChainMap
import plotly.graph_objects as go
layout = ChainMap(
dict(width=1000),
dict(width=500, height=500),
)
go.Figure(layout=layout)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/python/plotly/_plotly_utils/basevalidators.py at the validate_coerce() logic referenced in the issue. Check how the Figure(layout=ChainMap(...)) example is validated, then verify that arbitrary Mapping inputs are accepted without changing existing dict behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100