Skip to content

Commit a459709

Browse files
committed
Add type_check_only, TODO comment, and constrain django-stubs version
1 parent f135d2e commit a459709

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

stubs/channels/METADATA.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version = "4.*"
22
upstream_repository = "https://github.com/django/channels"
3-
requires = ["django-stubs", "asgiref"]
3+
requires = ["django-stubs>=4.2,<5.3", "asgiref"]
44

55
[tool.stubtest]
6-
skip = true # due to the need of django mypy plugin config, it should be skipped.
6+
skip = true # TODO: enable stubtest once Django mypy plugin config is supported
77
stubtest_requirements = ["daphne"]

stubs/channels/channels/routing.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any
1+
from typing import Any, type_check_only
22

33
from asgiref.typing import ASGIReceiveCallable, ASGISendCallable
44
from django.urls.resolvers import URLPattern
@@ -14,6 +14,7 @@ class ProtocolTypeRouter:
1414
def __init__(self, application_mapping: dict[str, Any]) -> None: ...
1515
async def __call__(self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: ...
1616

17+
@type_check_only
1718
class _ExtendedURLPattern(URLPattern):
1819
callback: _ASGIApplicationProtocol | URLRouter
1920

stubs/channels/channels/testing/http.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Iterable
2-
from typing import Literal, TypedDict
2+
from typing import Literal, TypedDict, type_check_only
33

44
from channels.testing.application import ApplicationCommunicator
55
from channels.utils import _ChannelApplication
@@ -10,6 +10,7 @@ class _HTTPTestResponse(TypedDict, total=False):
1010
headers: Iterable[tuple[bytes, bytes]]
1111
body: bytes
1212

13+
@type_check_only
1314
class _HTTPTestScope(TypedDict, total=False):
1415
type: Literal["http"]
1516
http_version: str

stubs/channels/channels/testing/live.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ from django.db.backends.sqlite3.base import DatabaseWrapper
1010
from django.test.testcases import TransactionTestCase
1111
from django.test.utils import modify_settings
1212

13-
DaphneProcess: TypeAlias = Any
13+
DaphneProcess: TypeAlias = Any # TODO: temporary hack for daphne.testing.DaphneProcess; remove once daphne provides types
1414

1515
_StaticWrapper: TypeAlias = Callable[[ProtocolTypeRouter], _ChannelApplication]
1616

stubs/channels/channels/testing/websocket.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from collections.abc import Iterable
2-
from typing import Any, Literal, TypedDict, overload
2+
from typing import Any, Literal, TypedDict, overload, type_check_only
33
from typing_extensions import NotRequired, TypeAlias
44

55
from asgiref.typing import ASGIVersions
66
from channels.testing.application import ApplicationCommunicator
77
from channels.utils import _ChannelApplication
88

9+
@type_check_only
910
class _WebsocketTestScope(TypedDict, total=False):
1011
spec_version: int
1112
type: Literal["websocket"]

stubs/channels/channels/utils.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Awaitable, Callable
2-
from typing import Any, Protocol
2+
from typing import Any, Protocol, type_check_only
33
from typing_extensions import TypeAlias
44

55
from asgiref.typing import ASGIApplication, ASGIReceiveCallable
@@ -8,7 +8,7 @@ def name_that_thing(thing: Any) -> str: ...
88
async def await_many_dispatch(
99
consumer_callables: list[Callable[[], Awaitable[ASGIReceiveCallable]]], dispatch: Callable[[dict[str, Any]], Awaitable[None]]
1010
) -> None: ...
11-
11+
@type_check_only
1212
class _MiddlewareProtocol(Protocol):
1313
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
1414
async def __call__(self, scope: Any, receive: Any, send: Any) -> Any: ...

0 commit comments

Comments
 (0)