plotly / plotly/dash

Named callback arguments could default to `no_update` if not provided

Open
#2,304 1 comment 0 reactions 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

Apologies if this is a duplicate, I tried a search and didn't see anything.

Is your feature request related to a problem? Please describe.

Imagine a callback with many outputs, using named keyword arguments.

@app.callback(
    output=dict(out_1=..., out_2=..., out_3=..., error_div=...),
    input=...
)
def my_callback(...):
   # I have to return a dict with _all_ outputs defined even if several are no_update
   # e.g., I have an error and I only want to report the error to the user
   return dict(out_1=no_update, out_2=no_update, out_3=no_update, error_div=...)

Describe the solution you'd like

It would be nice if, instead, if a key is not present it is assumed to be no_update by default, e.g. in the above example we could just return:

    return dict(error_div=...)

Currently, this would raise a schema error.

Describe alternatives you've considered
N/A

Additional context
N/A

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 at the callback output handling and the schema validation that currently rejects dictionaries missing declared output keys. Define the behavior so omitted named outputs are treated as no_update, then verify that returning only error_div works while invalid or unexpected keys still produce the appropriate schema error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.