From 23a23d437c34104b3c086390f6e299f1e1c85a36 Mon Sep 17 00:00:00 2001 From: Nikhil Rao Date: Wed, 26 Apr 2023 21:20:40 -0700 Subject: [PATCH] Fix f-strings in props (#891) --- pynecone/components/component.py | 4 ++-- tests/components/base/test_bare.py | 2 +- tests/components/forms/test_uploads.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pynecone/components/component.py b/pynecone/components/component.py index b93923e34..752e1cd87 100644 --- a/pynecone/components/component.py +++ b/pynecone/components/component.py @@ -120,7 +120,7 @@ class Component(Base, ABC): if types._issubclass(field_type, Var): try: # 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. if kwargs[key] is None: @@ -365,7 +365,7 @@ class Component(Base, ABC): children = [ child 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 ] return cls(children=children, **props) diff --git a/tests/components/base/test_bare.py b/tests/components/base/test_bare.py index 00e89477e..e05e621cc 100644 --- a/tests/components/base/test_bare.py +++ b/tests/components/base/test_bare.py @@ -22,4 +22,4 @@ def test_fstrings(contents, expected): """ comp = Bare.create(contents) comp.set_state(DefaultState) - assert str(comp) == expected + assert str(comp) == f"{{`{expected}`}}" diff --git a/tests/components/forms/test_uploads.py b/tests/components/forms/test_uploads.py index 025af06c4..4f6161d0d 100644 --- a/tests/components/forms/test_uploads.py +++ b/tests/components/forms/test_uploads.py @@ -53,7 +53,7 @@ def test_upload_component_render(upload_component): str(upload_component) == f" File(e)}>{({getRootProps, getInputProps}) => ({os.linesep}' + f"type={{`file`}}{{...getInputProps()}}/>{os.linesep}" f"{os.linesep}" "{`Drag and drop files here or click to select " "files`})}" @@ -72,7 +72,7 @@ def test_upload_component_with_props_render(upload_component_with_props): f"noDrag={{true}}{os.linesep}" "onDrop={e => File(e)}>{({getRootProps, getInputProps}) => ({os.linesep}' + f"type={{`file`}}{{...getInputProps()}}/>{os.linesep}" f"{os.linesep}" "{`Drag and drop files here or click to select " "files`})}"