Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Sep 7, 2024
1 parent d17a4d4 commit 7058795
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from strawberry.subscriptions.protocols.graphql_transport_ws.types import (
GraphQLTransportMessage,
)



class BaseGraphQLTransportWSHandler(ABC):
Expand Down Expand Up @@ -294,9 +293,9 @@ async def single_result() -> AsyncIterator[ExecutionResult]:
self.operations[message.id] = operation

async def operation_task(self, operation: Operation) -> None:
"""
The operation task's top level method. Cleans-up and de-registers the operation
once it is done.
"""The operation task's top level method.
Cleans-up and de-registers the operation once it is done.
"""
task = asyncio.current_task()
assert task is not None # for type checkers
Expand Down
8 changes: 3 additions & 5 deletions tests/websockets/test_graphql_transport_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,12 +1172,11 @@ async def test_task_error_handler(ws: WebSocketClient):
"""
# can't use a simple Event here, because the handler may run
# on a different thread
wakeup = False
wakeup = asyncio.Event()

Check warning on line 1175 in tests/websockets/test_graphql_transport_ws.py

View check run for this annotation

Codecov / codecov/patch

tests/websockets/test_graphql_transport_ws.py#L1175

Added line #L1175 was not covered by tests

# a replacement method which causes an error in th eTask
async def op(*args: Any, **kwargs: Any):
nonlocal wakeup
wakeup = True
wakeup.set()
raise ZeroDivisionError("test")

Check warning on line 1180 in tests/websockets/test_graphql_transport_ws.py

View check run for this annotation

Codecov / codecov/patch

tests/websockets/test_graphql_transport_ws.py#L1178-L1180

Added lines #L1178 - L1180 were not covered by tests

with patch.object(BaseGraphQLTransportWSHandler, "task_logger") as logger:
Expand All @@ -1193,8 +1192,7 @@ async def op(*args: Any, **kwargs: Any):
)

# wait for the error to be logged
while not wakeup:
await asyncio.sleep(0.01)
await wakeup.wait()

Check warning on line 1195 in tests/websockets/test_graphql_transport_ws.py

View check run for this annotation

Codecov / codecov/patch

tests/websockets/test_graphql_transport_ws.py#L1195

Added line #L1195 was not covered by tests
# and another little bit, for the thread to finish
await asyncio.sleep(0.01)
assert logger.exception.called

Check warning on line 1198 in tests/websockets/test_graphql_transport_ws.py

View check run for this annotation

Codecov / codecov/patch

tests/websockets/test_graphql_transport_ws.py#L1197-L1198

Added lines #L1197 - L1198 were not covered by tests

0 comments on commit 7058795

Please sign in to comment.