Allow reserved words as prop names
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Currently if someone makes a component that uses a python keyword or an R reserved word as a prop name, it just gets dropped from the generated component for that language. Here's the Python part (the important part being p not in python_keywords):
Silently dropping some props seems like it's definitely the wrong approach. We could fail to generate the component - that would be simple, and I'm not aware of any cases this would break now - but it's a silent failure, so ¯\_(ツ)_/¯ - also we'd have to fail on R keywords, and if we add another language potentially we'd add new keywords that could break existing components.
So I'd propose we find a way to allow keywords to be used as props, likely by altering the prop name / usage on the server side, like by adding a leading underscore? (may need to be language-dependent - leading underscore wouldn't work in R I don't believe) Note this would need to work consistently in both component construction and callback construction.
This came up during discussion of #874
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 with dash/development/_py_components_generation.py around lines 90-99 and trace how prop names are filtered for generated components. Check how component construction and callback construction represent those names across Python and R. Done means reserved-word props are preserved consistently without silently dropping them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, r
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100