MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / _r_code_in_tempfile

Function _r_code_in_tempfile

pre_commit/languages/r.py:111–120  ·  view source on GitHub ↗

To avoid quoting and escaping issues, avoid `Rscript [options] -e {expr}` but use `Rscript [options] path/to/file_with_expr.R`

(code: str)

Source from the content-addressed store, hash-verified

109
110@contextlib.contextmanager
111def _r_code_in_tempfile(code: str) -> Generator[str]:
112 """
113 To avoid quoting and escaping issues, avoid `Rscript [options] -e {expr}`
114 but use `Rscript [options] path/to/file_with_expr.R`
115 """
116 with tempfile.TemporaryDirectory() as tmpdir:
117 fname = os.path.join(tmpdir, 'script.R')
118 with open(fname, 'w') as f:
119 f.write(_inline_r_setup(textwrap.dedent(code)))
120 yield fname
121
122
123def get_env_patch(venv: str) -> PatchesT:

Callers 1

_execute_rFunction · 0.85

Calls 1

_inline_r_setupFunction · 0.85

Tested by

no test coverage detected