This is a compatibility shim for pre-3.7 when async outside of a function is a syntax error at the parse stage. It will return an abstract syntax tree parsed as if async and await outside of a function were not a syntax error.
(cell: str)
| 123 | |
| 124 | |
| 125 | def _async_parse_cell(cell: str) -> ast.AST: |
| 126 | """ |
| 127 | This is a compatibility shim for pre-3.7 when async outside of a function |
| 128 | is a syntax error at the parse stage. |
| 129 | |
| 130 | It will return an abstract syntax tree parsed as if async and await outside |
| 131 | of a function were not a syntax error. |
| 132 | """ |
| 133 | if sys.version_info < (3, 7): |
| 134 | # Prior to 3.7 you need to asyncify before parse |
| 135 | wrapped_parse_tree = ast.parse(_asyncify(cell)) |
| 136 | return wrapped_parse_tree.body[0].body[0] |
| 137 | else: |
| 138 | return ast.parse(cell) |
| 139 | |
| 140 | |
| 141 | def _should_be_async(cell: str) -> bool: |
no test coverage detected