Skip to content

Commit

Permalink
use f-string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Mar 8, 2021
1 parent 4ecde22 commit 50c1653
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pre_commit/languages/r.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def install_environment(
shutil.copy(prefix.path('renv.lock'), env_dir)
cmd_output_b(
'Rscript', '--vanilla', '-e',
"prefix_dir <- '" + prefix.prefix_dir + "'" +
"""
f"""\
prefix_dir <- "{prefix.prefix_dir}"
missing_pkgs <- setdiff(
"renv", unname(installed.packages()[, "Package"])
)
Expand All @@ -107,15 +107,15 @@ def install_environment(
'renv::activate("', file.path(getwd()), '"); '
)
writeLines(activate_statement, 'activate.R')
is_package <- tryCatch({
is_package <- tryCatch({{
content_desc <- read.dcf(file.path(prefix_dir, 'DESCRIPTION'))
suppressWarnings(unname(content_desc[,'Type']) == "Package")
},
}},
error = function(...) FALSE
)
if (is_package) {
if (is_package) {{
renv::install(prefix_dir)
}
}}
""",
cwd=env_dir,
)
Expand Down

0 comments on commit 50c1653

Please sign in to comment.