You are viewing an older version (9.5.0). Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.5.0 / IPython / core / async_helpers / _should_be_async

function

IPython.core.async_helpers:_should_be_async

source: /IPython/core/async_helpers.py :138

Signature

def   _should_be_async ( cell : str )  →  bool

Summary

Detect if a block of code need to be wrapped in an async def

Extended Summary

Attempt to parse the block of code, it it compile we're fine. Otherwise we wrap if and try to compile.

If it works, assume it should be async. Otherwise Return False.

Not handled yet: If the block of code has a return statement as the top level, it will be seen as async. This is a know limitation.

Aliases

  • IPython.core.async_helpers._should_be_async