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, /)
| 13 | |
| 14 | |
| 15 | def 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 | |
| 31 | def _relaxed_call_sig(func: Callable[..., Any]) -> Signature | None: |
no outgoing calls
searching dependent graphs…