Skip to content

Commit f26d8bf

Browse files
committed
chore: Refactor Dash validation layout logic
1 parent 3daf38e commit f26d8bf

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

dash/dash.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -707,36 +707,10 @@ def layout(self, value):
707707
and not self.validation_layout
708708
and not self.config.suppress_callback_exceptions
709709
):
710-
711-
def simple_clone(c, children=None):
712-
cls = type(c)
713-
# in Py3 we can use the __init__ signature to reduce to just
714-
# required args and id; in Py2 this doesn't work so we just
715-
# empty out children.
716-
sig = getattr(cls.__init__, "__signature__", None)
717-
props = {
718-
p: getattr(c, p)
719-
for p in c._prop_names # pylint: disable=protected-access
720-
if hasattr(c, p)
721-
and (
722-
p == "id" or not sig or sig.parameters[p].default == c.REQUIRED
723-
)
724-
}
725-
if props.get("children", children):
726-
props["children"] = children or []
727-
return cls(**props)
728-
710+
729711
layout_value = self._layout_value()
730-
731-
if isinstance(layout_value, (list, tuple)):
732-
layout_value = html.Div(children=layout_value)
733-
734712
_validate.validate_layout(value, layout_value)
735-
self.validation_layout = simple_clone(
736-
# pylint: disable=protected-access
737-
layout_value,
738-
[simple_clone(c) for c in layout_value._traverse_ids()],
739-
)
713+
self.validation_layout = layout_value
740714

741715
@property
742716
def index_string(self):

0 commit comments

Comments
 (0)