Skip to content

Commit

Permalink
Use async generator backport only on old python (#154)
Browse files Browse the repository at this point in the history
* requirements.txt: Conditionalize async_generator on python_version

* client.py: Import asynccontextmanager from contextlib on Python >= 3.7

* mypy.ini: Set python_version = 3.9 to match tox.ini

* nbclient/client.py: Suppress a mypy error

Co-authored-by: David Brochart <david.brochart@gmail.com>

Co-authored-by: David Brochart <david.brochart@gmail.com>
  • Loading branch information
mkoeppe and davidbrochart authored Aug 13, 2021
1 parent b85aaf3 commit 61fd479
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Global options:

[mypy]
python_version = 3.6
python_version = 3.9

# Per-module options:

Expand Down
7 changes: 6 additions & 1 deletion nbclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import signal
from textwrap import dedent

from async_generator import asynccontextmanager
try:
from contextlib import asynccontextmanager
except ImportError:
# Use the backport package async-generator for Python < 3.7.
# This should be removed when nbclient drops support for Python 3.6
from async_generator import asynccontextmanager # type: ignore
from contextlib import contextmanager

from time import monotonic
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
traitlets>=4.2
jupyter_client>=6.1.5
nbformat>=5.0
async_generator
async_generator; python_version<'3.7'
nest_asyncio

0 comments on commit 61fd479

Please sign in to comment.