From c1c2b60fce9716d4904d253b30edcb6699e3d13c 2020-10-02 02:10:58 From: farisachugthai Date: 2020-10-02 02:10:58 Subject: [PATCH] BUG: Fix mypy error Define ip only if we're type checking. --- diff --git a/IPython/core/tests/test_async_helpers.py b/IPython/core/tests/test_async_helpers.py index 11c4758..d23d9f1 100644 --- a/IPython/core/tests/test_async_helpers.py +++ b/IPython/core/tests/test_async_helpers.py @@ -1,5 +1,5 @@ """ -Test for async helpers. +Test for async helpers. Should only trigger on python 3.5+ or will have syntax errors. """ @@ -9,6 +9,12 @@ from textwrap import dedent, indent from unittest import TestCase from IPython.testing.decorators import skip_without import sys +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from IPython import get_ipython + ip = get_ipython() + iprc = lambda x: ip.run_cell(dedent(x)).raise_error() iprc_nr = lambda x: ip.run_cell(dedent(x)) @@ -275,7 +281,7 @@ class AsyncTest(TestCase): await sleep(0.1) """ ) - + if sys.version_info < (3,9): # new pgen parser in 3.9 does not raise MemoryError on too many nested # parens anymore