plotly / plotly/dash

Allow reserved words as prop names

Open
#878 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
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):

https://github.com/plotly/dash/blob/076f5ec92b9bd034d3904e97bd58fc6207482886/dash/development/_py_components_generation.py#L90-L99

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.