From 8e3f28ac381c70b511ca8a11c6a855b6f93de1b6 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 12:30:47 +0100 Subject: [PATCH 1/2] Enable PYI059 --- pyproject.toml | 2 +- stdlib/asyncio/queues.pyi | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ed4259fdb7ef..4dbe33b33b16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,7 @@ select = [ "PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics "PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`. "PYI058", # Use `{return_type}` as the return value for simple `{method}` methods - # "PYI059", # TODO: Add when dropping Python 3.9 support + "PYI059", # Checks for classes inheriting from typing.Generic[] where Generic[] is not the last base class in the bases tuple "PYI061", # Use `None` rather than `Literal[None]` "PYI062", # Duplicate literal member `{}` "PYI064", # `Final[Literal[{literal}]]` can be replaced with a bare Final diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index 2fa2226d0e6a..d482b62cbabb 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -24,9 +24,7 @@ _T = TypeVar("_T") if sys.version_info >= (3, 13): class QueueShutDown(Exception): ... -# If Generic[_T] is last and _LoopBoundMixin is object, pyright is unhappy. -# We can remove the noqa pragma when dropping 3.9 support. -class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059 +class Queue(_LoopBoundMixin, Generic[_T]): if sys.version_info >= (3, 10): def __init__(self, maxsize: int = 0) -> None: ... else: From 9dc354851a19d081aebe2f9e2a832ad12fe73408 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 14:50:15 +0100 Subject: [PATCH 2/2] Remove version_info branch --- stdlib/asyncio/queues.pyi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index d482b62cbabb..de19fa236ad3 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -4,10 +4,7 @@ from asyncio.events import AbstractEventLoop from types import GenericAlias from typing import Any, Generic, TypeVar -if sys.version_info >= (3, 10): - from .mixins import _LoopBoundMixin -else: - _LoopBoundMixin = object +from .mixins import _LoopBoundMixin class QueueEmpty(Exception): ... class QueueFull(Exception): ...