Skip to content

Commit 7bcb1c6

Browse files
authored
Merge pull request #276 from blink1073/fix-client-8-compat
2 parents a91d624 + af852a3 commit 7bcb1c6

File tree

8 files changed

+102
-88
lines changed

8 files changed

+102
-88
lines changed

.github/workflows/check-release.yml

-62
This file was deleted.

.github/workflows/python-package.yml

+50-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ on:
99
pull_request:
1010
branches: [ main ]
1111

12+
defaults:
13+
run:
14+
shell: bash -eux {0}
15+
1216
jobs:
1317
build:
1418

1519
runs-on: ubuntu-latest
1620
strategy:
1721
matrix:
18-
python-version: ['3.7', '3.8', '3.9', '3.10']
22+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
23+
fail-fast: false
1924

2025
steps:
2126
- uses: actions/checkout@v2
@@ -26,12 +31,50 @@ jobs:
2631
- name: Install dependencies
2732
run: |
2833
python -m pip install --upgrade pip check-manifest
29-
pip install pytest pytest-cov
30-
pip install .
34+
pip install pytest-cov
35+
pip install ".[test]"
3136
python -m ipykernel.kernelspec --user
3237
- name: Test with pytest
3338
run: |
34-
pytest --cov jupyter_console
35-
- name: Check Manifest
36-
run: |
37-
check-manifest
39+
pytest --cov jupyter_console || pytest jupyter_console --lf
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- uses: actions/setup-python@v2
46+
- name: Linting
47+
run: |
48+
pip install check-manifest mypy
49+
check-manifest
50+
mypy jupyter_console
51+
52+
check_release:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
57+
- uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
58+
with:
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
61+
check_links:
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v3
65+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
66+
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
67+
68+
test_minimum_verisons:
69+
name: Test Minimum Versions
70+
runs-on: ubuntu-latest
71+
timeout-minutes: 10
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
75+
with:
76+
dependency_type: minimum
77+
- name: Run the unit tests
78+
run: |
79+
pip install ".[test]"
80+
pytest || pytest --lf

docs/conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import shlex
1919
import shutil
20+
from typing import Dict
2021

2122
# If extensions (or modules to document with autodoc) are in another directory,
2223
# add these directories to sys.path here. If the directory is relative to the
@@ -74,7 +75,7 @@
7475
# built documents.
7576
#
7677

77-
version_ns = {}
78+
version_ns: Dict = {}
7879
version_py = os.path.join('..', 'jupyter_console', '_version.py')
7980
with open(version_py) as f:
8081
exec(compile(f.read(), version_py, 'exec'), version_ns)
@@ -229,7 +230,7 @@
229230

230231
# -- Options for LaTeX output ---------------------------------------------
231232

232-
latex_elements = {
233+
#latex_elements = {
233234
# The paper size ('letterpaper' or 'a4paper').
234235
#'papersize': 'letterpaper',
235236

@@ -241,7 +242,7 @@
241242

242243
# Latex figure (float) alignment
243244
#'figure_align': 'htbp',
244-
}
245+
#}
245246

246247
# Grouping the document tree into LaTeX files. List of tuples
247248
# (source start file, target name, title,

jupyter_console/app.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#-----------------------------------------------------------------------------
6464

6565

66-
class ZMQTerminalIPythonApp(JupyterApp, JupyterConsoleApp):
66+
class ZMQTerminalIPythonApp(JupyterApp, JupyterConsoleApp): # type:ignore[misc]
6767
name = "jupyter-console"
6868
version = __version__
6969
"""Start a terminal frontend to the IPython zmq kernel."""
@@ -85,9 +85,9 @@ class ZMQTerminalIPythonApp(JupyterApp, JupyterConsoleApp):
8585
"""
8686
examples = _examples
8787

88-
classes = [ZMQTerminalInteractiveShell] + JupyterConsoleApp.classes
89-
flags = Dict(flags)
90-
aliases = Dict(aliases)
88+
classes = [ZMQTerminalInteractiveShell] + JupyterConsoleApp.classes # type:ignore[operator]
89+
flags = Dict(flags) # type:ignore[assignment]
90+
aliases = Dict(aliases) # type:ignore[assignment]
9191
frontend_aliases = Any(frontend_aliases)
9292
frontend_flags = Any(frontend_flags)
9393

jupyter_console/ptshell.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import sys
1414
from tempfile import TemporaryDirectory
1515
import time
16+
import typing as t
1617
from warnings import warn
1718

1819
from typing import Dict as DictType, Any as AnyType
@@ -30,6 +31,7 @@
3031
Instance,
3132
Any,
3233
)
34+
import inspect
3335
from traitlets.config import SingletonConfigurable
3436

3537
from .completer import ZMQCompleter
@@ -76,7 +78,29 @@
7678
from pygments.util import ClassNotFound
7779
from pygments.token import Token
7880

79-
from jupyter_client.utils import run_sync
81+
from jupyter_core.utils import run_sync as _run_sync
82+
83+
84+
T = t.TypeVar("T")
85+
86+
87+
def run_sync(coro: t.Callable[..., t.Union[T, t.Awaitable[T]]]) -> t.Callable[..., T]:
88+
"""Wraps coroutine in a function that blocks until it has executed.
89+
90+
Parameters
91+
----------
92+
coro : coroutine-function
93+
The coroutine-function to be executed.
94+
95+
Returns
96+
-------
97+
result :
98+
Whatever the coroutine-function returns.
99+
"""
100+
if not inspect.iscoroutinefunction(coro):
101+
return t.cast(t.Callable[..., T], coro)
102+
return _run_sync(coro)
103+
80104

81105

82106
def ask_yes_no(prompt, default=None, interrupt=None):
@@ -316,7 +340,7 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
316340
),
317341
default_value="multicolumn",
318342
).tag(config=True)
319-
343+
320344
prompt_includes_vi_mode = Bool(True,
321345
help="Display the current vi mode (when using vi editing mode)."
322346
).tag(config=True)
@@ -374,7 +398,7 @@ def vi_mode(self):
374398
and self.prompt_includes_vi_mode):
375399
return '['+str(self.pt_cli.app.vi_state.input_mode)[3:6]+'] '
376400
return ''
377-
401+
378402
def get_prompt_tokens(self, ec=None):
379403
if ec is None:
380404
ec = self.execution_count

jupyter_console/tests/test_console.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
from traitlets.tests.utils import check_help_all_output
1515

1616

17-
@pytest.mark.xfail
18-
@pytest.mark.skipif(sys.platform == "win32", reason="skip on windows")
17+
should_skip = sys.platform == "win32" or sys.version_info < (3,8) or sys.version_info[:2] == (3, 10)
18+
19+
20+
@pytest.mark.skipif(should_skip, reason="not supported")
1921
def test_console_starts():
2022
"""test that `jupyter console` starts a terminal"""
2123
p, pexpect, t = start_console()
@@ -28,7 +30,8 @@ def test_help_output():
2830
"""jupyter console --help-all works"""
2931
check_help_all_output('jupyter_console')
3032

31-
@pytest.mark.xfail
33+
34+
@pytest.mark.skipif(should_skip, reason="not supported")
3235
def test_display_text():
3336
"Ensure display protocol plain/text key is supported"
3437
# equivalent of:
@@ -68,8 +71,8 @@ def start_console():
6871
except IOError:
6972
pytest.skip("Couldn't find command %s" % cmd)
7073

71-
# timeout after one minute
72-
t = 60
74+
# timeout after two minutes
75+
t = 120
7376
p.expect(r"In \[\d+\]", timeout=t)
7477
return p, pexpect, t
7578

mypy.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[mypy]
2-
python_version = 3.7
2+
python_version = 3.8
33
ignore_missing_imports = True
44
follow_imports = silent

setup.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,21 @@
4545
'Programming Language :: Python :: 3.7',
4646
'Programming Language :: Python :: 3.8',
4747
'Programming Language :: Python :: 3.9',
48+
'Programming Language :: Python :: 3.10',
49+
'Programming Language :: Python :: 3.11',
4850
],
4951
install_requires=[
5052
'jupyter_client>=7.0.0',
53+
'jupyter_core>=4.12,!=5.0.*',
5154
'ipython',
52-
'ipykernel', # bless IPython kernel for now
53-
'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1',
55+
'ipykernel>=6.14', # bless IPython kernel for now
56+
'prompt_toolkit>=3.0.30',
5457
'pygments',
58+
'pyzmq>=17',
59+
'traitlets>=5.4'
5560
],
5661
extras_require={
57-
'test:sys_platform != "win32"': ['pexpect'],
62+
'test': ['pexpect', 'pytest'],
5863
},
5964
python_requires='>=3.7',
6065
entry_points={

0 commit comments

Comments
 (0)