plotly / plotly/dash

[BUG] ctx.triggered_id is not recognized as a dict

Offen
#3,968 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

P3 size: 1 task
Vorherrschende Sprache
Python
Sterne
24.4k
Forks
2.3k
Ø Merge
2 T. 7 Std.
Gemergte PRs (30 T.)
13

Beschreibung

Describe your context
Please provide us your environment, so we can easily reproduce the issue.

dash                      4.4.1
dash_ag_grid              35.3.0
dash-extensions           2.0.6
dash-iconify              0.1.2
dash_mantine_components   2.8.0

Describe the bug

I am defining multiple dynamic components and set their id like this:

id={"type": "entry", "index": id},

where the value of "index" gets changed depending on the component.
Now, when I want to use the id in a pattern-matching callback, I need to get the value of "index"to search a sqlite database. When I use

ctx.triggered_id.get("index"))

however, VS Code produces an error and says: ""get" is no known attribute of "None"". The call however correctly returns the value of "index"

The same problem happens with ctx.triggered_id["index"], although the error then says: "None" object is not subscriptable.

FYI: I translated the error messages from German to English. They could be slightly inaccurate, though their meaning should be correct

Expected behavior

I would expect it to see a dict as a possible type of triggered_id, so that there is no error shown.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue nennt weder Quelldatei noch Test; beginne bei der Python-Definition von ctx.triggered_id und der Typisierung des Callback-Kontexts. Reproduziere den Zugriff per Pattern Matching mit den aufgeführten Dash-Versionen und prüfe anschließend, dass die statische Analyse den Dictionary-Zugriff erlaubt, während der Fall ohne Trigger weiterhin repräsentiert bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
63/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.