Skip to content

Commit c4b5540

Browse files
authored
Merge pull request #2915 from martian0x80/layout-function-patch
Fixes 'AttributeError' when layout is a function that returns a list of components in dash layout setter
2 parents 89e975f + e0e9a6a commit c4b5540

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1515
- [#2896](https://github.com/plotly/dash/pull/2896) The tabIndex parameter of Div can accept number or string type. Fixes [#2891](https://github.com/plotly/dash/issues/2891)
1616
- [#2900](https://github.com/plotly/dash/pull/2900) Allow strings in layout list. Fixes [#2890](https://github.com/plotly/dash/issues/2890)
1717
- [#2908](https://github.com/plotly/dash/pull/2908) Fix when environment variables are ignored by Dash.run() at runtime. Fixes [#2902](https://github.com/plotly/dash/issues/2902)
18+
- [#2915](https://github.com/plotly/dash/pull/2915) Fix 'AttributeError' when layout is a function that returns a list of components. Fixes [#2905](https://github.com/plotly/dash/issues/2905)
1819

1920
## [2.17.1] - 2024-06-12
2021

dash/dash.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -714,31 +714,9 @@ def layout(self, value):
714714
and not self.config.suppress_callback_exceptions
715715
):
716716

717-
def simple_clone(c, children=None):
718-
cls = type(c)
719-
# in Py3 we can use the __init__ signature to reduce to just
720-
# required args and id; in Py2 this doesn't work so we just
721-
# empty out children.
722-
sig = getattr(cls.__init__, "__signature__", None)
723-
props = {
724-
p: getattr(c, p)
725-
for p in c._prop_names # pylint: disable=protected-access
726-
if hasattr(c, p)
727-
and (
728-
p == "id" or not sig or sig.parameters[p].default == c.REQUIRED
729-
)
730-
}
731-
if props.get("children", children):
732-
props["children"] = children or []
733-
return cls(**props)
734-
735717
layout_value = self._layout_value()
736718
_validate.validate_layout(value, layout_value)
737-
self.validation_layout = simple_clone(
738-
# pylint: disable=protected-access
739-
layout_value,
740-
[simple_clone(c) for c in layout_value._traverse_ids()],
741-
)
719+
self.validation_layout = layout_value
742720

743721
@property
744722
def index_string(self):

0 commit comments

Comments
 (0)