-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import dash.dependencies | ||
|
||
# region Random component id generation | ||
|
||
_set_random_id = dash.development.base_component.Component._set_random_id | ||
_components_with_random_ids = [] | ||
|
||
|
||
def _collect_components_with_random_ids(self): | ||
if not hasattr(self, "id"): | ||
_components_with_random_ids.append(self) | ||
return _set_random_id(self) | ||
|
||
|
||
dash.development.base_component.Component._set_random_id = _collect_components_with_random_ids | ||
|
||
|
||
def assert_no_random_ids(): | ||
""" | ||
When a component is referenced in a callback, a random id is assigned automatically, if an id is not already set. | ||
This operation makes the application _stateful_, which is *not* recommended. This function raises an assertion | ||
error if any components have been assigned random ids, thereby forcing the developer to set ids for all components. | ||
""" | ||
if _components_with_random_ids: | ||
return | ||
raise AssertionError( | ||
f"The following components have random ids: {', '.join([str(c) for c in _components_with_random_ids])}") | ||
|
||
# endregion |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "dash-extensions" | ||
version = "1.0.13" | ||
version = "1.0.14" | ||
description = "Extensions for Plotly Dash." | ||
authors = ["emher <[email protected]>"] | ||
license = "MIT" | ||
|