MCPcopy
hub / github.com/pyodide/pyodide / run_js

Function run_js

src/py/pyodide/code.py:15–28  ·  view source on GitHub ↗

A wrapper for the :js:func:`eval` function. Runs ``code`` as a Javascript code string and returns the result. Unlike :js:func:`eval`, if ``code`` is not a string we raise a :py:exc:`TypeError`.

(code: str, /)

Source from the content-addressed store, hash-verified

13
14
15def run_js(code: str, /) -> Any:
16 """
17 A wrapper for the :js:func:`eval` function.
18
19 Runs ``code`` as a Javascript code string and returns the result. Unlike
20 :js:func:`eval`, if ``code`` is not a string we raise a :py:exc:`TypeError`.
21 """
22 from js import eval as eval_
23
24 if not isinstance(code, str):
25 raise TypeError(
26 f"argument should have type 'string' not type '{type(code).__name__}'"
27 )
28 return eval_(code)
29
30
31def _relaxed_call_sig(func: Callable[..., Any]) -> Signature | None:

Callers 15

test_pyproxy_classFunction · 0.90
test_pyproxy_tostringFunction · 0.90
test_pyproxy_refcountFunction · 0.90
test_pyproxy_destroyFunction · 0.90
test_pyproxy_iterFunction · 0.90
test_pyproxy_iter_errorFunction · 0.90
test_pyproxy_iter_error2Function · 0.90
test_get_empty_bufferFunction · 0.90
test_pyproxy_mixins1Function · 0.90
test_pyproxy_mixins31Function · 0.90
test_pyproxy_mixins41Function · 0.90

Calls

no outgoing calls

Tested by 15

test_pyproxy_classFunction · 0.72
test_pyproxy_tostringFunction · 0.72
test_pyproxy_refcountFunction · 0.72
test_pyproxy_destroyFunction · 0.72
test_pyproxy_iterFunction · 0.72
test_pyproxy_iter_errorFunction · 0.72
test_pyproxy_iter_error2Function · 0.72
test_get_empty_bufferFunction · 0.72
test_pyproxy_mixins1Function · 0.72
test_pyproxy_mixins31Function · 0.72
test_pyproxy_mixins41Function · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…