Repository navigation
[channels] Make URLRouter.routes a Collection #15080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0d165cf
79675e2
ea3fe35
331c3d1
f947fe4
97445ea
759abb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from collections.abc import Collection | ||
| from typing import Any, type_check_only | ||
|
|
||
| from asgiref.typing import ASGIReceiveCallable, ASGISendCallable, Scope | ||
|
|
@@ -19,9 +20,9 @@ class _ExtendedURLPattern(URLPattern): | |
| callback: _ASGIApplicationProtocol | URLRouter | ||
|
|
||
| class URLRouter: | ||
| routes: list[_ExtendedURLPattern | URLRouter] | ||
| routes: Collection[_ExtendedURLPattern | URLRouter] | ||
|
|
||
| def __init__(self, routes: list[_ExtendedURLPattern | URLRouter]) -> None: ... | ||
| def __init__(self, routes: Collection[_ExtendedURLPattern | URLRouter]) -> None: ... | ||
|
Comment on lines
+23
to
+25
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The typeshed standard for from collections.abc import Container
x: Container[int] = []
for y in x: # error: "Container[int]" has no attribute "__iter__" (not iterable)
reveal_type(y) # note: Revealed type is "Any"
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Collection is actually iterable (it's Sized + Iterable + Container). |
||
| async def __call__(self, scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: ... | ||
|
|
||
| class ChannelNameRouter: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,19 @@ | ||
| from collections.abc import Iterable | ||
|
|
||
| from asgiref.server import StatelessServer | ||
| from channels.layers import BaseChannelLayer | ||
| from channels.utils import _ChannelApplication | ||
|
|
||
| class Worker(StatelessServer): | ||
| channels: list[str] | ||
| channels: Iterable[str] | ||
| channel_layer: BaseChannelLayer | ||
|
|
||
| def __init__( | ||
| self, application: _ChannelApplication, channels: list[str], channel_layer: BaseChannelLayer, max_applications: int = 1000 | ||
| self, | ||
| application: _ChannelApplication, | ||
| channels: Iterable[str], | ||
| channel_layer: BaseChannelLayer, | ||
| max_applications: int = 1000, | ||
| ) -> None: ... | ||
| async def handle(self) -> None: ... | ||
| async def listener(self, channel: str) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be still needed.