Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
danplischke committed Aug 26, 2024
1 parent e0410be commit 870db53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions ariadne/asgi/handlers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ class ServerSentEventResponse(Response):

def __init__(
self,
*args,
generator: AsyncGenerator[GraphQLServerSentEvent, Any],
send_timeout: Optional[int] = None,
ping_interval: Optional[int] = None,
headers: Optional[Dict[str, str]] = None,
encoding: Optional[str] = None,
*args,
**kwargs,
):
"""Initializes the a SSE Response that send events generated by an async generator
Expand Down Expand Up @@ -198,16 +198,16 @@ def __init__(

@staticmethod
async def listen_for_disconnect(receive: Receive) -> None:
"""Listens for the client disconnect event and stops the streaming by exiting the infinite loop
this triggers the anyio CancelScope to cancel the TaskGroup
"""Listens for the client disconnect event and stops the streaming by exiting the infinite
loop this triggers the anyio CancelScope to cancel the TaskGroup
# Required arguments
`receive`: the starlette Receive object
"""
while True:
message = await receive()
if message["type"] == "http.disconnect":
logging.debug(f"Got event: http.disconnect. Stop streaming...")
logging.debug("Got event: http.disconnect. Stop streaming...")
break

def encode_event(self, event: GraphQLServerSentEvent) -> bytes:
Expand All @@ -219,8 +219,8 @@ def encode_event(self, event: GraphQLServerSentEvent) -> bytes:
return str(event).encode(self.encoding)

async def _ping(self, send: Send) -> None:
"""Sends a ping event to the client every `ping_interval` seconds gets cancelled if the client disconnects
through the anyio CancelScope of the TaskGroup
"""Sends a ping event to the client every `ping_interval` seconds gets
cancelled if the client disconnects through the anyio CancelScope of the TaskGroup
# Required arguments
`send`: the starlette Send object
Expand Down Expand Up @@ -755,8 +755,9 @@ async def sse_generate_error_response(
async def sse_subscribe_to_graphql(
self, query_document: DocumentNode, data: Any, context_value: Any
):
"""Main SSE subscription generator for the GraphQL query. Yields `GraphQLServerSentEvent` instances
and is to be consumed by a `ServerSentEventResponse` instance
"""Main SSE subscription generator for the GraphQL query.
Yields `GraphQLServerSentEvent` instances and is to be consumed by a
`ServerSentEventResponse` instance
# Required arguments
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async def test_root_generator(root, *_):
yield {"testRoot": root.get("test")}


async def test_slow_generator(_, info):
async def test_slow_generator(*_):
yield {"testSlow": "slow"}
await asyncio.sleep(20)
yield {"testSlow": "slow"}
Expand Down

0 comments on commit 870db53

Please sign in to comment.