Skip to content

Commit cb6ba11

Browse files
committed
Fix typing issues
1 parent c41c2db commit cb6ba11

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/graphql/execution/map_async_iterator.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from concurrent.futures import FIRST_COMPLETED
33
from inspect import isasyncgen, isawaitable
44
from types import TracebackType
5-
from typing import Any, AsyncIterable, Callable, Optional, Set, Type, Union, cast
5+
from typing import Any, AsyncIterable, Callable, Optional, Set, Type, Union
66

77
__all__ = ["MapAsyncIterator"]
88

@@ -85,11 +85,7 @@ async def athrow(
8585
if value is None:
8686
if traceback is None:
8787
raise type_ # pragma: no cover
88-
value = (
89-
type_
90-
if isinstance(value, BaseException)
91-
else cast(Type[BaseException], type_)()
92-
)
88+
value = type_ if isinstance(value, BaseException) else type_()
9389
if traceback is not None:
9490
value = value.with_traceback(traceback)
9591
raise value

tests/execution/test_subscribe.py

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

4-
from graphql.execution import MapAsyncIterator, create_source_event_stream, subscribe
4+
from graphql.execution import (
5+
ExecutionResult,
6+
MapAsyncIterator,
7+
create_source_event_stream,
8+
subscribe,
9+
)
510
from graphql.language import parse
611
from graphql.pyutils import SimplePubSub
712
from graphql.type import (
@@ -446,6 +451,8 @@ async def resolves_to_an_error_if_variables_were_wrong_type():
446451
# resolve to an ExecutionResult that contains an informative error description.
447452
result = await subscribe(schema, document, variable_values=variable_values)
448453

454+
assert isinstance(result, ExecutionResult)
455+
449456
assert result == (
450457
None,
451458
[
@@ -457,7 +464,9 @@ async def resolves_to_an_error_if_variables_were_wrong_type():
457464
],
458465
)
459466

460-
assert result.errors[0].original_error
467+
errors = result.errors
468+
assert errors
469+
assert errors[0].original_error
461470

462471

463472
# Once a subscription returns a valid AsyncIterator, it can still yield errors.

0 commit comments

Comments
 (0)