From 406a17592f1b7d5c2e4d79ce979566d80788e1df Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 20 Apr 2026 10:31:45 +0200 Subject: [PATCH 1/2] [channels] Compatibility fixes for django-stubs 6.0.3 `LazyObject` is generic since django-stubs 6.0.3. --- stubs/channels/METADATA.toml | 2 +- stubs/channels/channels/auth.pyi | 3 ++- stubs/channels/channels/consumer.pyi | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stubs/channels/METADATA.toml b/stubs/channels/METADATA.toml index cc2d2a599826..1eed45be8e4d 100644 --- a/stubs/channels/METADATA.toml +++ b/stubs/channels/METADATA.toml @@ -1,6 +1,6 @@ version = "4.3.*" upstream-repository = "https://github.com/django/channels" -dependencies = ["django-stubs>=4.2", "asgiref"] +dependencies = ["django-stubs>=6.0.3", "asgiref"] [tool.stubtest] mypy-plugins = ['mypy_django_plugin.main'] diff --git a/stubs/channels/channels/auth.pyi b/stubs/channels/channels/auth.pyi index b8594667e059..f6113b9fb03b 100644 --- a/stubs/channels/channels/auth.pyi +++ b/stubs/channels/channels/auth.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from asgiref.typing import ASGIReceiveCallable, ASGISendCallable from channels.middleware import BaseMiddleware from django.contrib.auth.backends import BaseBackend @@ -14,7 +15,7 @@ async def logout(scope: _ChannelScope) -> None: ... # Inherits AbstractBaseUser to improve autocomplete and show this is a lazy proxy for a user. # At runtime, it's just a LazyObject that wraps the actual user instance. -class UserLazyObject(AbstractBaseUser, LazyObject): ... +class UserLazyObject(AbstractBaseUser, LazyObject[Incomplete]): ... class AuthMiddleware(BaseMiddleware): def populate_scope(self, scope: _ChannelScope) -> None: ... diff --git a/stubs/channels/channels/consumer.pyi b/stubs/channels/channels/consumer.pyi index d48e679c923b..0a00a97fec95 100644 --- a/stubs/channels/channels/consumer.pyi +++ b/stubs/channels/channels/consumer.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Awaitable from typing import Any, ClassVar, Protocol, TypedDict, type_check_only @@ -11,7 +12,7 @@ from django.utils.functional import LazyObject # We subclass both for type checking purposes to expose SessionBase attributes, # and suppress mypy's "misc" error with `# type: ignore[misc]`. @type_check_only -class _LazySession(SessionBase, LazyObject): # type: ignore[misc] +class _LazySession(SessionBase, LazyObject[Incomplete]): # type: ignore[misc] _wrapped: SessionBase @type_check_only From 159a0d83e0f66a384adccb84f7d86d155a9b519c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 08:36:35 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/channels/channels/auth.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/channels/channels/auth.pyi b/stubs/channels/channels/auth.pyi index f6113b9fb03b..8c2361d3bbdd 100644 --- a/stubs/channels/channels/auth.pyi +++ b/stubs/channels/channels/auth.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete + from asgiref.typing import ASGIReceiveCallable, ASGISendCallable from channels.middleware import BaseMiddleware from django.contrib.auth.backends import BaseBackend