wrap code in async def definition. And setup a bit of context to run it later.
(code: str)
| 76 | |
| 77 | |
| 78 | def _asyncify(code: str) -> str: |
| 79 | """wrap code in async def definition. |
| 80 | |
| 81 | And setup a bit of context to run it later. |
| 82 | """ |
| 83 | res = dedent( |
| 84 | """ |
| 85 | async def __wrapper__(): |
| 86 | try: |
| 87 | {usercode} |
| 88 | finally: |
| 89 | locals() |
| 90 | """ |
| 91 | ).format(usercode=indent(code, " " * 8)) |
| 92 | return res |
| 93 | |
| 94 | |
| 95 | class _AsyncSyntaxErrorVisitor(ast.NodeVisitor): |
no test coverage detected