plotly / plotly/dash

Let the unspecified arguments of dict output of a callback function default to `dash.no_update` (or other user defined default)

Open
#1,983 0 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

If you use named arguments for the output a callback function, as in

@app.callback(
    output=dict(x=Output(...), y=Output(...)),
    inputs=dict(a=Input(...), b=Input(...)),
    state=dict(c=State(...))
)
def callback(b, c, a):
    return dict(x=a + b, y=b + c)

you have to specify all the arguments in the returning dict. But since named argument are useful especially when you have several output arguments, and if, like I experienced, you need to update only one or few arguments in the various return cases, it would be much more comfortable to return a dict specifying only those few arguments, instead of returning a long dict mostly made of dash.no_update.

I think the code would be shorter and clearer if the returning dict could default the unspecified named arguments to dash.no_update or some user defined value, like in defaultdict.

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 by tracing how dict outputs from callback functions are validated and normalized. Compare the existing dash.no_update behavior with omitted keys and the proposed user-defined default, then add focused tests for partial returns and default handling. Done means unspecified outputs consistently receive the selected default without changing explicitly returned values.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.