diff --git a/IPython/core/async_helpers.py b/IPython/core/async_helpers.py index c752dbd..8e6bf81 100644 --- a/IPython/core/async_helpers.py +++ b/IPython/core/async_helpers.py @@ -89,6 +89,7 @@ def _should_be_async(cell: str) -> bool: except SyntaxError: try: ast.parse(_asyncify(cell)) + # TODO verify ast has not "top level" return or yield. except SyntaxError: return False return True diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index e3f146a..49ae75d 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -154,7 +154,7 @@ def removed_co_newlocals(function:types.FunctionType) -> types.FunctionType: # async integration from .async_helpers import (_asyncio_runner, _asyncify) -if sys.version_info > (3,5): +if sys.version_info > (3, 5): from .async_helpers import _curio_runner, _trio_runner, _should_be_async else : _curio_runner = _trio_runner = None diff --git a/appveyor.yml b/appveyor.yml index c22865f..7fbecff 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,10 +8,6 @@ environment: PYTHON_VERSION: "3.6.x" PYTHON_ARCH: "32" - - PYTHON: "C:\\Python34-x64" - PYTHON_VERSION: "3.4.x" - PYTHON_ARCH: "64" - - PYTHON: "C:\\Python36-x64" PYTHON_VERSION: "3.6.x" PYTHON_ARCH: "64" diff --git a/docs/source/interactive/autoawait.rst b/docs/source/interactive/autoawait.rst index 35bd4e7..003bf56 100644 --- a/docs/source/interactive/autoawait.rst +++ b/docs/source/interactive/autoawait.rst @@ -3,12 +3,17 @@ Asynchronous in REPL: Autoawait =============================== -Starting with IPython 6.0, and when user Python 3.6 and above, IPython offer the -ability to run asynchronous code from the REPL. constructs which are +Starting with IPython 7.0, and when user Python 3.6 and above, IPython offer the +ability to run asynchronous code from the REPL. Constructs which are :exc:`SyntaxError` s in the Python REPL can be used seamlessly in IPython. -When a supported libray is used, IPython will automatically `await` Futures -and Coroutines in the REPL. This will happen if an :ref:`await ` (or `async`) is +The example given here are for terminal IPython, running async code in a +notebook interface or any other frontend using the Jupyter protocol will need to +use a newer version of IPykernel. The details of how async code runs in +IPykernel will differ between IPython, IPykernel and their versions. + +When a supported library is used, IPython will automatically `await` Futures +and Coroutines in the REPL. This will happen if an :ref:`await ` is use at top level scope, or if any structure valid only in `async def `_ function context are present. For example, the following being a syntax error in the @@ -29,7 +34,7 @@ Should behave as expected in the IPython REPL:: Python 3.6.0 Type 'copyright', 'credits' or 'license' for more information - IPython 6.0.0.dev -- An enhanced Interactive Python. Type '?' for help. + IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: import aiohttp ...: result = aiohttp.get('https://api.github.com') @@ -58,7 +63,9 @@ use the :magic:`%autoawait` magic to toggle the behavior at runtime:: By default IPython will assume integration with Python's provided :mod:`asyncio`, but integration with other libraries is provided. In particular -we provide experimental integration with the ``curio`` and ``trio`` library. +we provide experimental integration with the ``curio`` and ``trio`` library, the +later one being necessary if you require the ability to do nested call of +IPython's ``embed()`` functionality. You can switch current integration by using the ``c.InteractiveShell.loop_runner`` option or the ``autoawait