mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 04:25:50 +08:00
[channels] Use async def instead of a decorator (#15590)
This commit is contained in:
@@ -7,6 +7,10 @@ channels.auth.UserLazyObject.MultipleObjectsReturned
|
||||
channels.auth.UserLazyObject.NotUpdated
|
||||
channels.auth.UserLazyObject@AnnotatedWith
|
||||
|
||||
# "is not a function", because it's wrapped in database_sync_to_async,
|
||||
# which makes it a class instance.
|
||||
channels.consumer.SyncConsumer.dispatch
|
||||
|
||||
# database_sync_to_async is implemented as a class instance but stubbed as a function
|
||||
# for better type inference when used as decorator/function
|
||||
channels.db.database_sync_to_async
|
||||
|
||||
@@ -3,7 +3,6 @@ from typing import Any, ClassVar, Protocol, TypedDict, type_check_only
|
||||
|
||||
from asgiref.typing import ASGIReceiveCallable, ASGISendCallable, Scope, WebSocketScope
|
||||
from channels.auth import UserLazyObject
|
||||
from channels.db import database_sync_to_async
|
||||
from channels.layers import BaseChannelLayer
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.utils.functional import LazyObject
|
||||
@@ -70,6 +69,5 @@ class SyncConsumer(AsyncConsumer):
|
||||
|
||||
# Since we're overriding asynchronous methods with synchronous ones,
|
||||
# we need to use `# type: ignore[override]` to suppress mypy errors.
|
||||
@database_sync_to_async
|
||||
def dispatch(self, message: dict[str, Any]) -> None: ... # type: ignore[override]
|
||||
async def dispatch(self, message: dict[str, Any]) -> None: ... # type: ignore[override]
|
||||
def send(self, message: dict[str, Any]) -> None: ... # type: ignore[override]
|
||||
|
||||
Reference in New Issue
Block a user