Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unsupported format string passed to Button.__format__ #1024

Closed
ghost opened this issue Nov 22, 2019 · 2 comments
Closed

[BUG] Unsupported format string passed to Button.__format__ #1024

ghost opened this issue Nov 22, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 22, 2019

Context

dash                 1.6.0
dash-core-components 1.5.0
dash-html-components 1.0.1
dash-renderer        1.2.0
dash-table           4.5.0
dash-daq                  0.2.1
dash-bootstrap-components 0.7.2

Bug description

When I run my application, I receive following error :

Traceback (most recent call last):
File "app.py", line 452, in
@app.callback(
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\dash\dash.py", line 1264, in callback
self._validate_callback(output, inputs, state)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\dash\dash.py", line 921, in _validate_callback
if arg_id not in layout and arg_id != layout_id:
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\dash\development\base_component.py", line 257, in iter
for t in self._traverse():
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\dash\development\base_component.py", line 217, in _traverse
for t in self._traverse_with_paths():
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\dash\development\base_component.py", line 252, in _traverse_with_paths
for p, t in i._traverse_with_paths():
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\dash\development\base_component.py", line 244, in _traverse_with_paths
"(id={:s})".format(i.id)
TypeError: unsupported format string passed to Button.format

The error appear on a line where I define this callback :

@app.callback(
    Output('reportPid', 'data'),
    [Input('report1Button', 'n_clicks')],
    [State('pid1', 'data')]
)
def report1(n, data):
    return data

The error seems to be about naming of one of my button.

The weird thing is, if I remove this callback, no error.
I must be doing something wrong in this callback but I cannot see what, and the error is not helpful...

@ghost ghost added the dash-type-bug label Nov 22, 2019
@alexcjohnson
Copy link
Collaborator

I suspect somewhere in your layout you have a set of children that should be wrapped in an array and the second one is a Button - ie
html.Div(Something(...), Button(...), ...)
should be
html.Div([Something(...), Button(...), ...])
(isn't necessarily a Div but you get the point)

This is only showing up during callback definition because that's the first place we walk the layout tree.

I'm starting to think a v2 component API should only accept arrays for children... otherwise it's super tricky for us to figure out how to give a more helpful error for this case.

@ghost
Copy link
Author

ghost commented Nov 22, 2019

Awesome !

That's exactly it !
Thank you very much for the hint, I would never have found by myself...

Thanks again for the saved time !

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant