Fix f-strings in props (#891)
This commit is contained in:
parent
f0346506d7
commit
23a23d437c
@ -120,7 +120,7 @@ class Component(Base, ABC):
|
|||||||
if types._issubclass(field_type, Var):
|
if types._issubclass(field_type, Var):
|
||||||
try:
|
try:
|
||||||
# Try to create a var from the value.
|
# Try to create a var from the value.
|
||||||
kwargs[key] = Var.create(value)
|
kwargs[key] = Var.create(value, is_string=type(value) == str)
|
||||||
|
|
||||||
# Check that the var type is not None.
|
# Check that the var type is not None.
|
||||||
if kwargs[key] is None:
|
if kwargs[key] is None:
|
||||||
@ -365,7 +365,7 @@ class Component(Base, ABC):
|
|||||||
children = [
|
children = [
|
||||||
child
|
child
|
||||||
if isinstance(child, Component)
|
if isinstance(child, Component)
|
||||||
else Bare.create(contents=Var.create(child, is_string=True))
|
else Bare.create(contents=Var.create(child))
|
||||||
for child in children
|
for child in children
|
||||||
]
|
]
|
||||||
return cls(children=children, **props)
|
return cls(children=children, **props)
|
||||||
|
@ -22,4 +22,4 @@ def test_fstrings(contents, expected):
|
|||||||
"""
|
"""
|
||||||
comp = Bare.create(contents)
|
comp = Bare.create(contents)
|
||||||
comp.set_state(DefaultState)
|
comp.set_state(DefaultState)
|
||||||
assert str(comp) == expected
|
assert str(comp) == f"{{`{expected}`}}"
|
||||||
|
@ -53,7 +53,7 @@ def test_upload_component_render(upload_component):
|
|||||||
str(upload_component) == f"<ReactDropzone multiple={{true}}{os.linesep}"
|
str(upload_component) == f"<ReactDropzone multiple={{true}}{os.linesep}"
|
||||||
"onDrop={e => File(e)}>{({getRootProps, getInputProps}) => (<Box "
|
"onDrop={e => File(e)}>{({getRootProps, getInputProps}) => (<Box "
|
||||||
'sx={{"border": "1px dotted black"}}{...getRootProps()}><Input '
|
'sx={{"border": "1px dotted black"}}{...getRootProps()}><Input '
|
||||||
f'type="file"{{...getInputProps()}}/>{os.linesep}'
|
f"type={{`file`}}{{...getInputProps()}}/>{os.linesep}"
|
||||||
f"<Button>{{`select file`}}</Button>{os.linesep}"
|
f"<Button>{{`select file`}}</Button>{os.linesep}"
|
||||||
"<Text>{`Drag and drop files here or click to select "
|
"<Text>{`Drag and drop files here or click to select "
|
||||||
"files`}</Text></Box>)}</ReactDropzone>"
|
"files`}</Text></Box>)}</ReactDropzone>"
|
||||||
@ -72,7 +72,7 @@ def test_upload_component_with_props_render(upload_component_with_props):
|
|||||||
f"noDrag={{true}}{os.linesep}"
|
f"noDrag={{true}}{os.linesep}"
|
||||||
"onDrop={e => File(e)}>{({getRootProps, getInputProps}) => (<Box "
|
"onDrop={e => File(e)}>{({getRootProps, getInputProps}) => (<Box "
|
||||||
'sx={{"border": "1px dotted black"}}{...getRootProps()}><Input '
|
'sx={{"border": "1px dotted black"}}{...getRootProps()}><Input '
|
||||||
f'type="file"{{...getInputProps()}}/>{os.linesep}'
|
f"type={{`file`}}{{...getInputProps()}}/>{os.linesep}"
|
||||||
f"<Button>{{`select file`}}</Button>{os.linesep}"
|
f"<Button>{{`select file`}}</Button>{os.linesep}"
|
||||||
"<Text>{`Drag and drop files here or click to select "
|
"<Text>{`Drag and drop files here or click to select "
|
||||||
"files`}</Text></Box>)}</ReactDropzone>"
|
"files`}</Text></Box>)}</ReactDropzone>"
|
||||||
|
Loading…
Reference in New Issue
Block a user