Skip to content

Commit

Permalink
Improve safety of RFormatter.importable (#353)
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
shreve authored Aug 7, 2024
1 parent 55a9d04 commit 1e4e541
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jupyterlab_code_formatter/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1e4e541

Please sign in to comment.