Skip to content

Commit 00ebd94

Browse files
committed
anext() didn't become a builtin in Python 3.7
1 parent d3bdab4 commit 00ebd94

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

graphql/pyutils/event_emitter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Callable, Dict, List
22

3-
from asyncio import Queue, ensure_future
3+
from asyncio import AbstractEventLoop, Queue, ensure_future
44
from inspect import isawaitable
55

66
from collections import defaultdict
@@ -11,7 +11,7 @@
1111
class EventEmitter:
1212
"""A very simple EventEmitter."""
1313

14-
def __init__(self, loop=None) -> None:
14+
def __init__(self, loop: AbstractEventLoop=None) -> None:
1515
self.loop = loop
1616
self.listeners: Dict[str, List[Callable]] = defaultdict(list)
1717

tests/subscription/test_map_async_iterator.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55

66
from graphql.subscription.map_async_iterator import MapAsyncIterator
77

8-
try:
9-
# noinspection PyUnresolvedReferences,PyUnboundLocalVariable
10-
anext
11-
except NameError: # anext does not yet exist in Python 3.6
12-
async def anext(iterable):
13-
"""Return the next item from an async iterator."""
14-
return await iterable.__anext__()
8+
async def anext(iterable):
9+
"""Return the next item from an async iterator."""
10+
return await iterable.__anext__()
1511

1612

1713
def describe_map_async_iterator():

tests/subscription/test_subscribe.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@
2828
'inbox': GraphQLField(InboxType)})
2929

3030

31-
try:
32-
# noinspection PyUnresolvedReferences,PyUnboundLocalVariable
33-
anext
34-
except NameError: # anext does not yet exist in Python 3.6
35-
async def anext(iterable):
36-
"""Return the next item from an async iterator."""
37-
return await iterable.__anext__()
31+
async def anext(iterable):
32+
"""Return the next item from an async iterator."""
33+
return await iterable.__anext__()
3834

3935

4036
def email_schema_with_resolvers(subscribe_fn=None, resolve_fn=None):

0 commit comments

Comments
 (0)