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

required children prop #2218

Merged
merged 19 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dash/development/_py_components_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ def __init__(self, {default_argtext}):
_explicit_args = kwargs.pop('_explicit_args')
_locals = locals()
_locals.update(kwargs) # For wildcard attrs and excess named props
args = {{k: _locals[k] for k in _explicit_args if k != 'children'}}
args = {args}
for k in {required_props}:
if k not in args:
raise TypeError(
'Required argument `' + k + '` was not specified.')
if 'children' in {required_props} and 'children' not in _explicit_args:
raise TypeError(
'Required argument children was not specified.')
super({typename}, self).__init__({argtext})
'''

Expand All @@ -92,12 +95,14 @@ def __init__(self, {default_argtext}):

# pylint: disable=unused-variable
prop_keys = list(props.keys())
if "children" in props:
if "children" in props and "children" in list_of_valid_keys:
prop_keys.remove("children")
default_argtext = "children=None, "
args = "{k: _locals[k] for k in _explicit_args if k != 'children'}"
argtext = "children=children, **args"
else:
default_argtext = ""
args = "{k: _locals[k] for k in _explicit_args}"
argtext = "**args"
default_arglist = [
(
Expand Down Expand Up @@ -131,6 +136,7 @@ def __init__(self, {default_argtext}):
list_of_valid_keys=list_of_valid_keys,
docstring=docstring,
default_argtext=default_argtext,
args=args,
argtext=argtext,
required_props=required_args,
children_props=nodes,
Expand Down
3 changes: 2 additions & 1 deletion dash/testing/application_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import runpy
import requests
import psutil

# pylint: disable=no-member
import multiprocess

Expand Down Expand Up @@ -216,7 +217,7 @@ def __init__(self, keep_open=False, stop_timeout=3):

# pylint: disable=arguments-differ
def start(self, app, start_timeout=3, **kwargs):
self.port = kwargs.get('port', 8050)
self.port = kwargs.get("port", 8050)

def target():
app.scripts.config.serve_locally = True
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/devtools/test_hot_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def new_text(n):

try:
until(
lambda: dash_duo_mp.driver.execute_script("return window.cheese") == "gouda",
lambda: dash_duo_mp.driver.execute_script("return window.cheese")
== "gouda",
timeout=10,
)
finally:
Expand All @@ -97,7 +98,8 @@ def new_text(n):
f.write(old_hard)

until(
lambda: dash_duo_mp.driver.execute_script("return window.cheese") == "roquefort",
lambda: dash_duo_mp.driver.execute_script("return window.cheese")
== "roquefort",
timeout=10,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/renderer/test_component_as_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_rdcap001_component_as_prop(dash_duo):
"id": "multi2",
"first": Span("foo"),
"second": Span("bar"),
}
},
],
),
]
Expand Down