Skip to content

Commit 8f448ac

Browse files
committed
Previous Python version support fixed.
1 parent d2cbb4d commit 8f448ac

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

channels_graphql_ws/graphql_ws_consumer.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@
4747
import traceback
4848
import weakref
4949
from collections.abc import Sequence
50-
from typing import Any, AsyncIterator, Awaitable, Callable, Optional, Type, Union, cast
50+
from typing import (
51+
Any,
52+
AsyncIterator,
53+
Awaitable,
54+
Callable,
55+
Dict,
56+
Optional,
57+
Type,
58+
Union,
59+
cast,
60+
)
5161

5262
import asgiref.sync
5363
import channels.db
@@ -109,7 +119,7 @@ class GraphqlWsConsumer(ch_websocket.AsyncJsonWebsocketConsumer):
109119

110120
# The message sent to the client when subscription activation
111121
# confirmation is enabled.
112-
subscription_confirmation_message: dict[str, Any] = {"data": None, "errors": None}
122+
subscription_confirmation_message: Dict[str, Any] = {"data": None, "errors": None}
113123

114124
# Issue a warning to the log when operation/resolver takes longer
115125
# than specified number in seconds. None disables the warning.
@@ -212,7 +222,7 @@ class _SubscriptionExecutionContext(graphql.ExecutionContext):
212222

213223
@staticmethod
214224
def build_response(
215-
data: Optional[dict[str, Any]], errors: list[graphql.GraphQLError]
225+
data: Optional[Dict[str, Any]], errors: list[graphql.GraphQLError]
216226
) -> graphql.ExecutionResult:
217227
"""Remove skipped subscription events from results.
218228
@@ -254,14 +264,14 @@ def __init__(self, *args, **kwargs):
254264
)
255265

256266
# Registry of active (subscribed) subscriptions.
257-
self._subscriptions: dict[
267+
self._subscriptions: Dict[
258268
int, GraphqlWsConsumer._SubInf
259269
] = {} # {'<sid>': '<SubInf>', ...}
260270
self._sids_by_group = {} # {'<grp>': ['<sid0>', '<sid1>', ...], ...}
261271

262272
# Tasks which send notifications to clients indexed by an
263273
# operation/subscription id.
264-
self._notifier_tasks: dict[int, asyncio.Task] = {}
274+
self._notifier_tasks: Dict[int, asyncio.Task] = {}
265275

266276
# Task that sends keepalive messages periodically.
267277
self._keepalive_task = None
@@ -839,7 +849,7 @@ async def _on_gql_start__subscribe(
839849
document: graphql.DocumentNode,
840850
root_value: Any = None,
841851
context_value: Any = None,
842-
variable_values: Optional[dict[str, Any]] = None,
852+
variable_values: Optional[Dict[str, Any]] = None,
843853
operation_name: Optional[str] = None,
844854
field_resolver: Optional[graphql.GraphQLFieldResolver] = None,
845855
subscribe_field_resolver: Optional[graphql.GraphQLFieldResolver] = None,

example/example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import pathlib
2525
from collections import defaultdict
26-
from typing import Any, DefaultDict
26+
from typing import Any, DefaultDict, Dict
2727

2828
import asgiref
2929
import channels
@@ -43,7 +43,7 @@
4343

4444
# Fake storage for the chat history. Do not do this in production, it
4545
# lives only in memory of the running server and does not persist.
46-
chats: DefaultDict[str, list[dict[str, Any]]] = defaultdict(list)
46+
chats: DefaultDict[str, list[Dict[str, Any]]] = defaultdict(list)
4747

4848

4949
# ---------------------------------------------------------------------- TYPES & QUERIES

0 commit comments

Comments
 (0)