From d432fd0adae706e0ae470b3d87eb948f0ab6f148 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:23:38 -0600 Subject: [PATCH 01/15] fix client 8 compat --- jupyter_console/ptshell.py | 20 +++++++++----------- jupyter_console/tests/test_console.py | 3 +-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/jupyter_console/ptshell.py b/jupyter_console/ptshell.py index 1dae25b..f707235 100644 --- a/jupyter_console/ptshell.py +++ b/jupyter_console/ptshell.py @@ -76,8 +76,6 @@ from pygments.util import ClassNotFound from pygments.token import Token -from jupyter_client.utils import run_sync - def ask_yes_no(prompt, default=None, interrupt=None): """Asks a question and returns a boolean (y/n) answer. @@ -707,8 +705,8 @@ def run_cell(self, cell, store_history=True): return # flush stale replies, which could have been ignored, due to missed heartbeats - while run_sync(self.client.shell_channel.msg_ready)(): - run_sync(self.client.shell_channel.get_msg)() + while self.client.shell_channel.msg_ready(): + self.client.shell_channel.get_msg() # execute takes 'hidden', which is the inverse of store_hist msg_id = self.client.execute(cell, not store_history) @@ -742,7 +740,7 @@ def run_cell(self, cell, store_history=True): def handle_execute_reply(self, msg_id, timeout=None): kwargs = {"timeout": timeout} - msg = run_sync(self.client.shell_channel.get_msg)(**kwargs) + msg = self.client.shell_channel.get_msg(**kwargs) if msg["parent_header"].get("msg_id", None) == msg_id: self.handle_iopub(msg_id) @@ -782,7 +780,7 @@ def handle_is_complete_reply(self, msg_id, timeout=None): msg = None try: kwargs = {"timeout": timeout} - msg = run_sync(self.client.shell_channel.get_msg)(**kwargs) + msg = self.client.shell_channel.get_msg(**kwargs) except Empty: warn('The kernel did not respond to an is_complete_request. ' 'Setting `use_kernel_is_complete` to False.') @@ -851,8 +849,8 @@ def handle_iopub(self, msg_id=''): It only displays output that is caused by this session. """ - while run_sync(self.client.iopub_channel.msg_ready)(): - sub_msg = run_sync(self.client.iopub_channel.get_msg)() + while self.client.iopub_channel.msg_ready(): + sub_msg = self.client.iopub_channel.get_msg() msg_type = sub_msg['header']['msg_type'] # Update execution_count in case it changed in another session @@ -1005,7 +1003,7 @@ def handle_image_callable(self, data, mime): def handle_input_request(self, msg_id, timeout=0.1): """ Method to capture raw_input """ - req = run_sync(self.client.stdin_channel.get_msg)(timeout=timeout) + req = self.client.stdin_channel.get_msg(timeout=timeout) # in case any iopub came while we were waiting: self.handle_iopub(msg_id) if msg_id == req["parent_header"].get("msg_id"): @@ -1034,6 +1032,6 @@ def double_int(sig, frame): # only send stdin reply if there *was not* another request # or execution finished while we were reading. - if not (run_sync(self.client.stdin_channel.msg_ready)() or - run_sync(self.client.shell_channel.msg_ready)()): + if not (self.client.stdin_channel.msg_ready() or + self.client.shell_channel.msg_ready()): self.client.input(raw_data) diff --git a/jupyter_console/tests/test_console.py b/jupyter_console/tests/test_console.py index fb8cc0d..4f5b8b7 100644 --- a/jupyter_console/tests/test_console.py +++ b/jupyter_console/tests/test_console.py @@ -14,7 +14,6 @@ from traitlets.tests.utils import check_help_all_output -@pytest.mark.xfail @pytest.mark.skipif(sys.platform == "win32", reason="skip on windows") def test_console_starts(): """test that `jupyter console` starts a terminal""" @@ -28,7 +27,7 @@ def test_help_output(): """jupyter console --help-all works""" check_help_all_output('jupyter_console') -@pytest.mark.xfail + def test_display_text(): "Ensure display protocol plain/text key is supported" # equivalent of: From 60e4bcbe223c86d47726df71dc17ac422955db0b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:28:57 -0600 Subject: [PATCH 02/15] clean up ci --- .github/workflows/check-release.yml | 62 ------------------------- .github/workflows/python-package.yml | 32 ++++++++++++- setup.py | 4 +- test.txt | 67 ++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/check-release.yml create mode 100644 test.txt diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml deleted file mode 100644 index 643ffda..0000000 --- a/.github/workflows/check-release.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Check Release -on: - push: - branches: ["main"] - pull_request: - branches: ["*"] - -permissions: - contents: write - -jobs: - check_release: - runs-on: ubuntu-latest - strategy: - matrix: - group: [check_release, link_check] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - architecture: "x64" - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: "14.x" - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - name: Cache pip - uses: actions/cache@v1 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }} - restore-keys: | - ${{ runner.os }}-pip- - ${{ runner.os }}-pip- - - name: Cache checked links - if: ${{ matrix.group == 'link_check' }} - uses: actions/cache@v2 - with: - path: ~/.cache/pytest-link-check - key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/*.md', '**/*.rst') }}-md-links - restore-keys: | - ${{ runner.os }}-linkcheck- - - name: Upgrade packaging dependencies - run: | - pip install --upgrade pip setuptools wheel --user - - name: Install Dependencies - run: | - pip install -e . - - name: Check Release - if: ${{ matrix.group == 'check_release' }} - uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Check Links - if: ${{ matrix.group == 'link_check' }} - uses: jupyter-server/jupyter_releaser/.github/actions/check-links@v1 diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 73af585..95a430a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,7 +15,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + fail-fast: false steps: - uses: actions/checkout@v2 @@ -35,3 +36,32 @@ jobs: - name: Check Manifest run: | check-manifest + + check_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + check_links: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1 + + test_minimum_verisons: + name: Test Minimum Versions + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + with: + dependency_type: minimum + - name: Run the unit tests + run: | + pytest diff --git a/setup.py b/setup.py index c449c8a..fefa62e 100644 --- a/setup.py +++ b/setup.py @@ -45,11 +45,13 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ], install_requires=[ 'jupyter_client>=7.0.0', 'ipython', - 'ipykernel', # bless IPython kernel for now + 'ipykernel>=6.14', # bless IPython kernel for now 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1', 'pygments', ], diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..9394da2 --- /dev/null +++ b/test.txt @@ -0,0 +1,67 @@ + +> +yup +yup +yup +yup +> + +> +yup +yup +yup +> + +> +yup +yup +yup +yup +> +> +> +> + +> +yup +yup +yup +yup +> + +> +yup +yup +yup +> + +> +yup +yup +yup +yup +> + +> +yup +yup +yup +yup +> + +> +yup +yup +yup +yup +yup +> + +> +yup +yup +yup +yup +> + + From 3d9d8d2762a3c632554e148426cbe5ed7149f3ea Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:34:41 -0600 Subject: [PATCH 03/15] remove test file --- test.txt | 67 -------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 test.txt diff --git a/test.txt b/test.txt deleted file mode 100644 index 9394da2..0000000 --- a/test.txt +++ /dev/null @@ -1,67 +0,0 @@ - -> -yup -yup -yup -yup -> - -> -yup -yup -yup -> - -> -yup -yup -yup -yup -> -> -> -> - -> -yup -yup -yup -yup -> - -> -yup -yup -yup -> - -> -yup -yup -yup -yup -> - -> -yup -yup -yup -yup -> - -> -yup -yup -yup -yup -yup -> - -> -yup -yup -yup -yup -> - - From 5c7ffd67319ea1211f2cc10a8403e1b83852c65c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:35:53 -0600 Subject: [PATCH 04/15] update test deps --- .github/workflows/python-package.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 95a430a..695e336 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip check-manifest - pip install pytest pytest-cov + pip install pytest-cov pip install . python -m ipykernel.kernelspec --user - name: Test with pytest diff --git a/setup.py b/setup.py index fefa62e..7ec2b32 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ 'pygments', ], extras_require={ - 'test:sys_platform != "win32"': ['pexpect'], + 'test': ['pexpect', 'pytest'], }, python_requires='>=3.7', entry_points={ From 59e74b06ae82e5b4167787bc740d84ac815db0bd Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:38:22 -0600 Subject: [PATCH 05/15] fix pytest install --- .github/workflows/python-package.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 695e336..d0a64cb 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -28,11 +28,11 @@ jobs: run: | python -m pip install --upgrade pip check-manifest pip install pytest-cov - pip install . + pip install ".[test]" python -m ipykernel.kernelspec --user - name: Test with pytest run: | - pytest --cov jupyter_console + pytest --cov jupyter_console || pytest jupyter_console --lf - name: Check Manifest run: | check-manifest @@ -64,4 +64,5 @@ jobs: dependency_type: minimum - name: Run the unit tests run: | - pytest + pip install pytest + pytest || pytest --lf From d32ad8eec4f7f02c827b080c182c2ddf1690239f Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:45:30 -0600 Subject: [PATCH 06/15] fix it up --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 7ec2b32..9cdb907 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,8 @@ 'ipykernel>=6.14', # bless IPython kernel for now 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1', 'pygments', + 'pyzmq>=17', + 'traitlets>5.4' ], extras_require={ 'test': ['pexpect', 'pytest'], From e06cf2dc735693371ba5464be6bdc3df8e86a336 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:47:28 -0600 Subject: [PATCH 07/15] try again --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d0a64cb..416f064 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -64,5 +64,5 @@ jobs: dependency_type: minimum - name: Run the unit tests run: | - pip install pytest + pip install ".[test]" pytest || pytest --lf From 3539bb1e3df1133d09a3dd21fe6aaade964d51fc Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 12:54:48 -0600 Subject: [PATCH 08/15] try again --- jupyter_console/tests/test_console.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jupyter_console/tests/test_console.py b/jupyter_console/tests/test_console.py index 4f5b8b7..3fd1f8c 100644 --- a/jupyter_console/tests/test_console.py +++ b/jupyter_console/tests/test_console.py @@ -67,8 +67,8 @@ def start_console(): except IOError: pytest.skip("Couldn't find command %s" % cmd) - # timeout after one minute - t = 60 + # timeout after two minutes + t = 120 p.expect(r"In \[\d+\]", timeout=t) return p, pexpect, t diff --git a/setup.py b/setup.py index 9cdb907..efaca0a 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1', 'pygments', 'pyzmq>=17', - 'traitlets>5.4' + 'traitlets>=5.4' ], extras_require={ 'test': ['pexpect', 'pytest'], From 00949126a2a4dee1165e124caa3e4915674fb418 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Feb 2023 13:14:17 -0600 Subject: [PATCH 09/15] try again --- jupyter_console/tests/test_console.py | 6 +++++- setup.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jupyter_console/tests/test_console.py b/jupyter_console/tests/test_console.py index 3fd1f8c..2b4c05b 100644 --- a/jupyter_console/tests/test_console.py +++ b/jupyter_console/tests/test_console.py @@ -14,7 +14,10 @@ from traitlets.tests.utils import check_help_all_output -@pytest.mark.skipif(sys.platform == "win32", reason="skip on windows") +should_skip = sys.platform == "win32" or sys.version_info < (3,8) + + +@pytest.mark.skipif(should_skip, reason="not supported") def test_console_starts(): """test that `jupyter console` starts a terminal""" p, pexpect, t = start_console() @@ -28,6 +31,7 @@ def test_help_output(): check_help_all_output('jupyter_console') +@pytest.mark.skipif(should_skip, reason="not supported") def test_display_text(): "Ensure display protocol plain/text key is supported" # equivalent of: diff --git a/setup.py b/setup.py index efaca0a..0772ade 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ 'jupyter_client>=7.0.0', 'ipython', 'ipykernel>=6.14', # bless IPython kernel for now - 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1', + 'prompt_toolkit>=3.0.30', 'pygments', 'pyzmq>=17', 'traitlets>=5.4' From 22694132e50a63c8a30ca7cb9c077e05561f0f92 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 9 Feb 2023 09:56:35 -0600 Subject: [PATCH 10/15] try seeting bash default --- .github/workflows/python-package.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 416f064..707ce8d 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -9,6 +9,10 @@ on: pull_request: branches: [ main ] +defaults: + run: + shell: bash -eux {0} + jobs: build: From 256b58614fae99bbd3f1798ddb8eb9bd1563312b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 9 Feb 2023 10:18:13 -0600 Subject: [PATCH 11/15] add client 7 support --- .github/workflows/python-package.yml | 4 ++- docs/conf.py | 7 ++-- jupyter_console/app.py | 8 ++--- jupyter_console/ptshell.py | 48 +++++++++++++++++++++------ jupyter_console/tests/test_console.py | 1 + mypy.ini | 2 +- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 707ce8d..3c08ded 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -37,9 +37,11 @@ jobs: - name: Test with pytest run: | pytest --cov jupyter_console || pytest jupyter_console --lf - - name: Check Manifest + - name: Linting run: | check-manifest + pip install mypy + mypy . check_release: runs-on: ubuntu-latest diff --git a/docs/conf.py b/docs/conf.py index a61206f..fd908b2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,6 +17,7 @@ import os import shlex import shutil +from typing import Dict # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -74,7 +75,7 @@ # built documents. # -version_ns = {} +version_ns: Dict = {} version_py = os.path.join('..', 'jupyter_console', '_version.py') with open(version_py) as f: exec(compile(f.read(), version_py, 'exec'), version_ns) @@ -229,7 +230,7 @@ # -- Options for LaTeX output --------------------------------------------- -latex_elements = { +#latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', @@ -241,7 +242,7 @@ # Latex figure (float) alignment #'figure_align': 'htbp', -} +#} # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, diff --git a/jupyter_console/app.py b/jupyter_console/app.py index fb2518e..b68b4d7 100644 --- a/jupyter_console/app.py +++ b/jupyter_console/app.py @@ -63,7 +63,7 @@ #----------------------------------------------------------------------------- -class ZMQTerminalIPythonApp(JupyterApp, JupyterConsoleApp): +class ZMQTerminalIPythonApp(JupyterApp, JupyterConsoleApp): # type:ignore[misc] name = "jupyter-console" version = __version__ """Start a terminal frontend to the IPython zmq kernel.""" @@ -85,9 +85,9 @@ class ZMQTerminalIPythonApp(JupyterApp, JupyterConsoleApp): """ examples = _examples - classes = [ZMQTerminalInteractiveShell] + JupyterConsoleApp.classes - flags = Dict(flags) - aliases = Dict(aliases) + classes = [ZMQTerminalInteractiveShell] + JupyterConsoleApp.classes # type:ignore[operator] + flags = Dict(flags) # type:ignore[assignment] + aliases = Dict(aliases) # type:ignore[assignment] frontend_aliases = Any(frontend_aliases) frontend_flags = Any(frontend_flags) diff --git a/jupyter_console/ptshell.py b/jupyter_console/ptshell.py index f707235..ef7ba4e 100644 --- a/jupyter_console/ptshell.py +++ b/jupyter_console/ptshell.py @@ -13,6 +13,7 @@ import sys from tempfile import TemporaryDirectory import time +import typing as t from warnings import warn from typing import Dict as DictType, Any as AnyType @@ -30,6 +31,7 @@ Instance, Any, ) +import inspect from traitlets.config import SingletonConfigurable from .completer import ZMQCompleter @@ -76,6 +78,30 @@ from pygments.util import ClassNotFound from pygments.token import Token +from jupyter_core.utils import run_sync as _run_sync + + +T = t.TypeVar("T") + + +def run_sync(coro: t.Callable[..., t.Union[T, t.Awaitable[T]]]) -> t.Callable[..., T]: + """Wraps coroutine in a function that blocks until it has executed. + + Parameters + ---------- + coro : coroutine-function + The coroutine-function to be executed. + + Returns + ------- + result : + Whatever the coroutine-function returns. + """ + if not inspect.iscoroutinefunction(coro): + return t.cast(t.Callable[..., T], coro) + return _run_sync(coro) + + def ask_yes_no(prompt, default=None, interrupt=None): """Asks a question and returns a boolean (y/n) answer. @@ -314,7 +340,7 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable): ), default_value="multicolumn", ).tag(config=True) - + prompt_includes_vi_mode = Bool(True, help="Display the current vi mode (when using vi editing mode)." ).tag(config=True) @@ -372,7 +398,7 @@ def vi_mode(self): and self.prompt_includes_vi_mode): return '['+str(self.pt_cli.app.vi_state.input_mode)[3:6]+'] ' return '' - + def get_prompt_tokens(self, ec=None): if ec is None: ec = self.execution_count @@ -705,8 +731,8 @@ def run_cell(self, cell, store_history=True): return # flush stale replies, which could have been ignored, due to missed heartbeats - while self.client.shell_channel.msg_ready(): - self.client.shell_channel.get_msg() + while run_sync(self.client.shell_channel.msg_ready)(): + run_sync(self.client.shell_channel.get_msg)() # execute takes 'hidden', which is the inverse of store_hist msg_id = self.client.execute(cell, not store_history) @@ -740,7 +766,7 @@ def run_cell(self, cell, store_history=True): def handle_execute_reply(self, msg_id, timeout=None): kwargs = {"timeout": timeout} - msg = self.client.shell_channel.get_msg(**kwargs) + msg = run_sync(self.client.shell_channel.get_msg)(**kwargs) if msg["parent_header"].get("msg_id", None) == msg_id: self.handle_iopub(msg_id) @@ -780,7 +806,7 @@ def handle_is_complete_reply(self, msg_id, timeout=None): msg = None try: kwargs = {"timeout": timeout} - msg = self.client.shell_channel.get_msg(**kwargs) + msg = run_sync(self.client.shell_channel.get_msg)(**kwargs) except Empty: warn('The kernel did not respond to an is_complete_request. ' 'Setting `use_kernel_is_complete` to False.') @@ -849,8 +875,8 @@ def handle_iopub(self, msg_id=''): It only displays output that is caused by this session. """ - while self.client.iopub_channel.msg_ready(): - sub_msg = self.client.iopub_channel.get_msg() + while run_sync(self.client.iopub_channel.msg_ready)(): + sub_msg = run_sync(self.client.iopub_channel.get_msg)() msg_type = sub_msg['header']['msg_type'] # Update execution_count in case it changed in another session @@ -1003,7 +1029,7 @@ def handle_image_callable(self, data, mime): def handle_input_request(self, msg_id, timeout=0.1): """ Method to capture raw_input """ - req = self.client.stdin_channel.get_msg(timeout=timeout) + req = run_sync(self.client.stdin_channel.get_msg)(timeout=timeout) # in case any iopub came while we were waiting: self.handle_iopub(msg_id) if msg_id == req["parent_header"].get("msg_id"): @@ -1032,6 +1058,6 @@ def double_int(sig, frame): # only send stdin reply if there *was not* another request # or execution finished while we were reading. - if not (self.client.stdin_channel.msg_ready() or - self.client.shell_channel.msg_ready()): + if not (run_sync(self.client.stdin_channel.msg_ready)() or + run_sync(self.client.shell_channel.msg_ready)()): self.client.input(raw_data) diff --git a/jupyter_console/tests/test_console.py b/jupyter_console/tests/test_console.py index 2b4c05b..5484da6 100644 --- a/jupyter_console/tests/test_console.py +++ b/jupyter_console/tests/test_console.py @@ -21,6 +21,7 @@ def test_console_starts(): """test that `jupyter console` starts a terminal""" p, pexpect, t = start_console() + import pdb; pdb.set_trace() p.sendline("5") p.expect([r"Out\[\d+\]: 5", pexpect.EOF], timeout=t) p.expect([r"In \[\d+\]", pexpect.EOF], timeout=t) diff --git a/mypy.ini b/mypy.ini index cb3c188..7c1be49 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,4 +1,4 @@ [mypy] -python_version = 3.7 +python_version = 3.8 ignore_missing_imports = True follow_imports = silent From eb238126007e4d6577c1dc5d1c0be961dabf027e Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 9 Feb 2023 10:18:51 -0600 Subject: [PATCH 12/15] remove debug statement --- jupyter_console/tests/test_console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/jupyter_console/tests/test_console.py b/jupyter_console/tests/test_console.py index 5484da6..2b4c05b 100644 --- a/jupyter_console/tests/test_console.py +++ b/jupyter_console/tests/test_console.py @@ -21,7 +21,6 @@ def test_console_starts(): """test that `jupyter console` starts a terminal""" p, pexpect, t = start_console() - import pdb; pdb.set_trace() p.sendline("5") p.expect([r"Out\[\d+\]: 5", pexpect.EOF], timeout=t) p.expect([r"In \[\d+\]", pexpect.EOF], timeout=t) From 145d70f90fcfaddff9ad12556f87ad15a6896475 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 9 Feb 2023 10:20:49 -0600 Subject: [PATCH 13/15] limit mypy search location --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 3c08ded..4366ec2 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -41,7 +41,7 @@ jobs: run: | check-manifest pip install mypy - mypy . + mypy jupyter_console check_release: runs-on: ubuntu-latest From 19b367164da93a596b4caaec69447a70d1eefed1 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 9 Feb 2023 10:24:26 -0600 Subject: [PATCH 14/15] cleanup --- .github/workflows/python-package.yml | 16 +++++++++++----- setup.py | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 4366ec2..35804d2 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -37,11 +37,17 @@ jobs: - name: Test with pytest run: | pytest --cov jupyter_console || pytest jupyter_console --lf - - name: Linting - run: | - check-manifest - pip install mypy - mypy jupyter_console + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Linting + run: | + pip install check-manifest mypy + check-manifest + mypy jupyter_console check_release: runs-on: ubuntu-latest diff --git a/setup.py b/setup.py index 0772ade..ccad24c 100644 --- a/setup.py +++ b/setup.py @@ -50,6 +50,7 @@ ], install_requires=[ 'jupyter_client>=7.0.0', + 'jupyter_core>=4.12,!=5.0.*', 'ipython', 'ipykernel>=6.14', # bless IPython kernel for now 'prompt_toolkit>=3.0.30', From af852a3be96b84518b75c48d8b4a9f9927b2de9b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 9 Feb 2023 10:59:18 -0600 Subject: [PATCH 15/15] add py310 skips --- jupyter_console/tests/test_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_console/tests/test_console.py b/jupyter_console/tests/test_console.py index 2b4c05b..f1fcf84 100644 --- a/jupyter_console/tests/test_console.py +++ b/jupyter_console/tests/test_console.py @@ -14,7 +14,7 @@ from traitlets.tests.utils import check_help_all_output -should_skip = sys.platform == "win32" or sys.version_info < (3,8) +should_skip = sys.platform == "win32" or sys.version_info < (3,8) or sys.version_info[:2] == (3, 10) @pytest.mark.skipif(should_skip, reason="not supported")