From 4da83055e2bd0c5096d648d7f36f37d881adf2f0 Mon Sep 17 00:00:00 2001 From: geckguy Date: Tue, 13 Jun 2023 01:20:43 +0530 Subject: [PATCH 1/8] Better Error message if no backend installed #1042 --- src/py/reactpy/reactpy/backend/default.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index 4dfeb23e8..1c264e37c 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -6,6 +6,7 @@ from typing import Any, NoReturn from reactpy.backend.types import BackendImplementation +from reactpy.backend.utils import SUPPORTED_PACKAGES from reactpy.backend.utils import all_implementations from reactpy.types import RootComponentConstructor @@ -59,7 +60,10 @@ def _default_implementation() -> BackendImplementation[Any]: implementation = next(all_implementations()) except StopIteration: # nocov logger.debug("Backend implementation import failed", exc_info=exc_info()) - msg = "No built-in server implementation installed." + supported_backends = ', '.join(SUPPORTED_PACKAGES) + msg = "It seems you haven't installed any built-in backends. \n" \ + "To resolve this issue, you can install a backend like 'reactpy[starlette]' or any other supported backend.\n" \ + f"The list of supported backends is: {supported_backends}." raise RuntimeError(msg) from None else: _DEFAULT_IMPLEMENTATION = implementation From 70b908ac17271d59b17433f0521680a2dc8b222f Mon Sep 17 00:00:00 2001 From: geckguy Date: Tue, 13 Jun 2023 02:00:15 +0530 Subject: [PATCH 2/8] change the error message as requested --- src/py/reactpy/reactpy/backend/default.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index 1c264e37c..b7b7e0cc6 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -61,9 +61,10 @@ def _default_implementation() -> BackendImplementation[Any]: except StopIteration: # nocov logger.debug("Backend implementation import failed", exc_info=exc_info()) supported_backends = ', '.join(SUPPORTED_PACKAGES) - msg = "It seems you haven't installed any built-in backends. \n" \ - "To resolve this issue, you can install a backend like 'reactpy[starlette]' or any other supported backend.\n" \ - f"The list of supported backends is: {supported_backends}." + msg = "It seems you haven't installed an backend. To resolve this issue, you can install a backend by running \n"\ + "\n" \ + 'pip install "reactpy[starlette]"\n'\ + f"Other supported backends include: {supported_backends}." raise RuntimeError(msg) from None else: _DEFAULT_IMPLEMENTATION = implementation From 3efd27f98dc3d8b0395047bb2f36a253f91bb669 Mon Sep 17 00:00:00 2001 From: Abhiram <78226909+geckguy@users.noreply.github.com> Date: Tue, 13 Jun 2023 02:06:46 +0530 Subject: [PATCH 3/8] Update src/py/reactpy/reactpy/backend/default.py Co-authored-by: Ryan Morshead --- src/py/reactpy/reactpy/backend/default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index b7b7e0cc6..bec7717bf 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -63,7 +63,7 @@ def _default_implementation() -> BackendImplementation[Any]: supported_backends = ', '.join(SUPPORTED_PACKAGES) msg = "It seems you haven't installed an backend. To resolve this issue, you can install a backend by running \n"\ "\n" \ - 'pip install "reactpy[starlette]"\n'\ + 'pip install "reactpy[starlette]"\n\n'\ f"Other supported backends include: {supported_backends}." raise RuntimeError(msg) from None else: From 602959616d4dd75c60e2d10575bf29e471261063 Mon Sep 17 00:00:00 2001 From: geckguy Date: Tue, 13 Jun 2023 02:19:30 +0530 Subject: [PATCH 4/8] fix linting issues --- src/py/reactpy/reactpy/backend/default.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index bec7717bf..a77c8b3c8 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -6,8 +6,7 @@ from typing import Any, NoReturn from reactpy.backend.types import BackendImplementation -from reactpy.backend.utils import SUPPORTED_PACKAGES -from reactpy.backend.utils import all_implementations +from reactpy.backend.utils import SUPPORTED_PACKAGES, all_implementations from reactpy.types import RootComponentConstructor logger = getLogger(__name__) @@ -60,11 +59,12 @@ def _default_implementation() -> BackendImplementation[Any]: implementation = next(all_implementations()) except StopIteration: # nocov logger.debug("Backend implementation import failed", exc_info=exc_info()) - supported_backends = ', '.join(SUPPORTED_PACKAGES) - msg = "It seems you haven't installed an backend. To resolve this issue, you can install a backend by running \n"\ - "\n" \ - 'pip install "reactpy[starlette]"\n\n'\ - f"Other supported backends include: {supported_backends}." + supported_backends = ", ".join(SUPPORTED_PACKAGES) + msg = ("It seems you haven't installed a backend. To resolve this issue, " + "you can install a backend by running:\n\n" + 'pip install "reactpy[starlette]"\n\n' + f"Other supported backends include: {supported_backends}.") + raise RuntimeError(msg) from None else: _DEFAULT_IMPLEMENTATION = implementation From 9028c58648e1a705ba26db0899439503bd9e60b2 Mon Sep 17 00:00:00 2001 From: Abhiram <78226909+geckguy@users.noreply.github.com> Date: Tue, 13 Jun 2023 02:26:18 +0530 Subject: [PATCH 5/8] Update src/py/reactpy/reactpy/backend/default.py Co-authored-by: Ryan Morshead --- src/py/reactpy/reactpy/backend/default.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index a77c8b3c8..b1c404c3c 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -60,10 +60,12 @@ def _default_implementation() -> BackendImplementation[Any]: except StopIteration: # nocov logger.debug("Backend implementation import failed", exc_info=exc_info()) supported_backends = ", ".join(SUPPORTED_PACKAGES) - msg = ("It seems you haven't installed a backend. To resolve this issue, " - "you can install a backend by running:\n\n" - 'pip install "reactpy[starlette]"\n\n' - f"Other supported backends include: {supported_backends}.") + msg = ( + "It seems you haven't installed a backend. To resolve this issue, " + "you can install a backend by running:\n\n" + 'pip install "reactpy[starlette]"\n\n' + f"Other supported backends include: {supported_backends}." + ) raise RuntimeError(msg) from None else: From 6570a611e189c1bd96df5bc65abddc68eec33661 Mon Sep 17 00:00:00 2001 From: geckguy Date: Tue, 13 Jun 2023 02:30:55 +0530 Subject: [PATCH 6/8] Improve readability --- src/py/reactpy/reactpy/backend/default.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index b1c404c3c..3544efc29 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -62,8 +62,11 @@ def _default_implementation() -> BackendImplementation[Any]: supported_backends = ", ".join(SUPPORTED_PACKAGES) msg = ( "It seems you haven't installed a backend. To resolve this issue, " + "you can install a backend by running:\n\n" + 'pip install "reactpy[starlette]"\n\n' + f"Other supported backends include: {supported_backends}." ) From 15425084f050643530d04ef3c029a7a35cffe7f6 Mon Sep 17 00:00:00 2001 From: Ryan Morshead Date: Mon, 12 Jun 2023 15:40:03 -0600 Subject: [PATCH 7/8] Update src/py/reactpy/reactpy/backend/default.py --- src/py/reactpy/reactpy/backend/default.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index 3544efc29..512407c19 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -62,14 +62,10 @@ def _default_implementation() -> BackendImplementation[Any]: supported_backends = ", ".join(SUPPORTED_PACKAGES) msg = ( "It seems you haven't installed a backend. To resolve this issue, " - "you can install a backend by running:\n\n" - 'pip install "reactpy[starlette]"\n\n' - f"Other supported backends include: {supported_backends}." ) - raise RuntimeError(msg) from None else: _DEFAULT_IMPLEMENTATION = implementation From f25dc26a735536ba00f054733b73cf48bdbfef24 Mon Sep 17 00:00:00 2001 From: geckguy Date: Tue, 13 Jun 2023 16:00:35 +0530 Subject: [PATCH 8/8] make text bold --- src/py/reactpy/reactpy/backend/default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/reactpy/reactpy/backend/default.py b/src/py/reactpy/reactpy/backend/default.py index 512407c19..4ca192c1c 100644 --- a/src/py/reactpy/reactpy/backend/default.py +++ b/src/py/reactpy/reactpy/backend/default.py @@ -63,7 +63,7 @@ def _default_implementation() -> BackendImplementation[Any]: msg = ( "It seems you haven't installed a backend. To resolve this issue, " "you can install a backend by running:\n\n" - 'pip install "reactpy[starlette]"\n\n' + '\033[1mpip install "reactpy[starlette]"\033[0m\n\n' f"Other supported backends include: {supported_backends}." ) raise RuntimeError(msg) from None