Skip to content

Commit

Permalink
Fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Sep 3, 2024
1 parent c41c2db commit cb6ba11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/graphql/execution/map_async_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from concurrent.futures import FIRST_COMPLETED
from inspect import isasyncgen, isawaitable
from types import TracebackType
from typing import Any, AsyncIterable, Callable, Optional, Set, Type, Union, cast
from typing import Any, AsyncIterable, Callable, Optional, Set, Type, Union

__all__ = ["MapAsyncIterator"]

Expand Down Expand Up @@ -85,11 +85,7 @@ async def athrow(
if value is None:
if traceback is None:
raise type_ # pragma: no cover
value = (
type_
if isinstance(value, BaseException)
else cast(Type[BaseException], type_)()
)
value = type_ if isinstance(value, BaseException) else type_()
if traceback is not None:
value = value.with_traceback(traceback)
raise value
Expand Down
13 changes: 11 additions & 2 deletions tests/execution/test_subscribe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import asyncio
from typing import Any, Callable, Dict, List

from graphql.execution import MapAsyncIterator, create_source_event_stream, subscribe
from graphql.execution import (
ExecutionResult,
MapAsyncIterator,
create_source_event_stream,
subscribe,
)
from graphql.language import parse
from graphql.pyutils import SimplePubSub
from graphql.type import (
Expand Down Expand Up @@ -446,6 +451,8 @@ async def resolves_to_an_error_if_variables_were_wrong_type():
# resolve to an ExecutionResult that contains an informative error description.
result = await subscribe(schema, document, variable_values=variable_values)

assert isinstance(result, ExecutionResult)

assert result == (
None,
[
Expand All @@ -457,7 +464,9 @@ async def resolves_to_an_error_if_variables_were_wrong_type():
],
)

assert result.errors[0].original_error
errors = result.errors
assert errors
assert errors[0].original_error


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

0 comments on commit cb6ba11

Please sign in to comment.