From d1d779bc373ac60178d06f8bd6784b67b080115b Mon Sep 17 00:00:00 2001 From: Violet Shreve Date: Mon, 5 Aug 2024 11:54:59 -0400 Subject: [PATCH] Improve safety of RFormatter.importable Previously, if the system was missing Rscript, an exception would be thrown from RFormatter.importable. In some configurations, this exception caused a noisy and annoying error message, "Unable to find default formatters to use" --- jupyterlab_code_formatter/formatters.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jupyterlab_code_formatter/formatters.py b/jupyterlab_code_formatter/formatters.py index ac7d668..5c93fe2 100644 --- a/jupyterlab_code_formatter/formatters.py +++ b/jupyterlab_code_formatter/formatters.py @@ -361,6 +361,9 @@ def package_name(self) -> str: @property def importable(self) -> bool: + if not command_exist("Rscript"): + return False + package_location = subprocess.run( ["Rscript", "-e", f"cat(system.file(package='{self.package_name}'))"], capture_output=True,