plotly / plotly/dash

Allow reserved words as prop names

Aperta
#878 5 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature P3
Lingua principale
Python
Stelle
24.4k
Fork
2.3k
Merge medio
2g 7h
PR unite (30g)
13

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da dash/development/_py_components_generation.py intorno alle righe 90-99 e segui il modo in cui i nomi delle prop vengono filtrati per i componenti generati. Verifica come la costruzione dei componenti e la costruzione delle callback rappresentano questi nomi in Python e R. Il lavoro è completo quando le prop che sono parole riservate vengono preservate in modo coerente senza essere eliminate silenziosamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python, r
Ambito
api, backend-api-design
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.