|
47 | 47 | import traceback |
48 | 48 | import weakref |
49 | 49 | 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 | +) |
51 | 61 |
|
52 | 62 | import asgiref.sync |
53 | 63 | import channels.db |
@@ -109,7 +119,7 @@ class GraphqlWsConsumer(ch_websocket.AsyncJsonWebsocketConsumer): |
109 | 119 |
|
110 | 120 | # The message sent to the client when subscription activation |
111 | 121 | # 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} |
113 | 123 |
|
114 | 124 | # Issue a warning to the log when operation/resolver takes longer |
115 | 125 | # than specified number in seconds. None disables the warning. |
@@ -212,7 +222,7 @@ class _SubscriptionExecutionContext(graphql.ExecutionContext): |
212 | 222 |
|
213 | 223 | @staticmethod |
214 | 224 | def build_response( |
215 | | - data: Optional[dict[str, Any]], errors: list[graphql.GraphQLError] |
| 225 | + data: Optional[Dict[str, Any]], errors: list[graphql.GraphQLError] |
216 | 226 | ) -> graphql.ExecutionResult: |
217 | 227 | """Remove skipped subscription events from results. |
218 | 228 |
|
@@ -254,14 +264,14 @@ def __init__(self, *args, **kwargs): |
254 | 264 | ) |
255 | 265 |
|
256 | 266 | # Registry of active (subscribed) subscriptions. |
257 | | - self._subscriptions: dict[ |
| 267 | + self._subscriptions: Dict[ |
258 | 268 | int, GraphqlWsConsumer._SubInf |
259 | 269 | ] = {} # {'<sid>': '<SubInf>', ...} |
260 | 270 | self._sids_by_group = {} # {'<grp>': ['<sid0>', '<sid1>', ...], ...} |
261 | 271 |
|
262 | 272 | # Tasks which send notifications to clients indexed by an |
263 | 273 | # operation/subscription id. |
264 | | - self._notifier_tasks: dict[int, asyncio.Task] = {} |
| 274 | + self._notifier_tasks: Dict[int, asyncio.Task] = {} |
265 | 275 |
|
266 | 276 | # Task that sends keepalive messages periodically. |
267 | 277 | self._keepalive_task = None |
@@ -839,7 +849,7 @@ async def _on_gql_start__subscribe( |
839 | 849 | document: graphql.DocumentNode, |
840 | 850 | root_value: Any = None, |
841 | 851 | context_value: Any = None, |
842 | | - variable_values: Optional[dict[str, Any]] = None, |
| 852 | + variable_values: Optional[Dict[str, Any]] = None, |
843 | 853 | operation_name: Optional[str] = None, |
844 | 854 | field_resolver: Optional[graphql.GraphQLFieldResolver] = None, |
845 | 855 | subscribe_field_resolver: Optional[graphql.GraphQLFieldResolver] = None, |
|
0 commit comments