-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fixes 'AttributeError' when layout is a function that returns a list of components in dash layout setter #2915
Conversation
@alexcjohnson I see this comment from a couple years ago mention this fix is mostly to empty out children for Python 2. I don't see any other uses, think we can remove the simple_clone function ? |
We certainly don’t need to be maintaining any py2 code anymore, so yeah I think you’re right, let’s remove it. |
dash/dash.py
Outdated
if isinstance(layout_value, (list, tuple)): | ||
layout_value = html.Div(children=layout_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can delete the function simple_clone
and assign the self.validation_layout = layout_value
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, will make requested changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, seems like there is some formatting error to fix (npm run format
) then we can merge 🎉
Should I commit the other files that were formatted as well? |
No, I don't think it should have formatted all those files. npm probably took the wrong version of black, make sure the venv is activated before running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 Look good, thank you.
Thanks, that was indeed the problem. Sorry, for being clueless. |
Fixes #2905
Changes as the proposed solution suggested, layout setter throws an
AttributeError
when layout is a function that returns a list of components. The solution checks if thelayout_value
is an instance oflist
ortuple
, if it is, it wraps it in ahtml.Div
component, otherwise proceeds as usual.Contributor Checklist
optionals
CHANGELOG.md