From 7fc50c6cf2fd2226f0d8c6b957d6617195eb76ba Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Thu, 9 Feb 2023 17:59:24 +0000 Subject: [PATCH] Revert changes to `stubs/pika` to workaround the pyright bug --- .../pika/pika/adapters/asyncio_connection.pyi | 5 ++--- stubs/pika/pika/adapters/base_connection.pyi | 5 ++--- .../pika/pika/adapters/blocking_connection.pyi | 5 ++--- stubs/pika/pika/channel.pyi | 6 +++--- stubs/pika/pika/connection.pyi | 18 ++++++++++-------- stubs/pika/pika/spec.pyi | 10 +++++----- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/stubs/pika/pika/adapters/asyncio_connection.pyi b/stubs/pika/pika/adapters/asyncio_connection.pyi index 621eb6fa2743..57a3257cd565 100644 --- a/stubs/pika/pika/adapters/asyncio_connection.pyi +++ b/stubs/pika/pika/adapters/asyncio_connection.pyi @@ -1,8 +1,7 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from asyncio import AbstractEventLoop from collections.abc import Callable from logging import Logger -from typing_extensions import Self from ..connection import Parameters from .base_connection import BaseConnection @@ -12,7 +11,7 @@ LOGGER: Logger class AsyncioConnection(BaseConnection): def __init__( - self, + self: Self, parameters: Parameters | None = ..., on_open_callback: Callable[[Self], object] | None = ..., on_open_error_callback: Callable[[Self, BaseException], object] | None = ..., diff --git a/stubs/pika/pika/adapters/base_connection.pyi b/stubs/pika/pika/adapters/base_connection.pyi index db129fa75c6b..3cf7ed97f354 100644 --- a/stubs/pika/pika/adapters/base_connection.pyi +++ b/stubs/pika/pika/adapters/base_connection.pyi @@ -1,7 +1,6 @@ import abc -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from collections.abc import Callable -from typing_extensions import Self from ..adapters.utils import nbio_interface from ..connection import Connection @@ -10,7 +9,7 @@ LOGGER: Incomplete class BaseConnection(Connection, metaclass=abc.ABCMeta): def __init__( - self, + self: Self, parameters, on_open_callback: Callable[[Self], object] | None, on_open_error_callback: Callable[[Self, BaseException], object] | None, diff --git a/stubs/pika/pika/adapters/blocking_connection.pyi b/stubs/pika/pika/adapters/blocking_connection.pyi index 5f330829c7a9..c0907f2f37d9 100644 --- a/stubs/pika/pika/adapters/blocking_connection.pyi +++ b/stubs/pika/pika/adapters/blocking_connection.pyi @@ -1,7 +1,6 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from collections.abc import Generator, Sequence from typing import NamedTuple -from typing_extensions import Self from ..connection import Parameters from ..data import _ArgumentMapping @@ -56,7 +55,7 @@ class BlockingConnection: def __init__( self, parameters: Parameters | Sequence[Parameters] | None = ..., _impl_class: Incomplete | None = ... ) -> None: ... - def __enter__(self) -> Self: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, exc_type: object, value: object, traceback: object) -> None: ... def add_on_connection_blocked_callback(self, callback) -> None: ... def add_on_connection_unblocked_callback(self, callback) -> None: ... diff --git a/stubs/pika/pika/channel.pyi b/stubs/pika/pika/channel.pyi index 3f28e847c17f..30631f00fdaa 100644 --- a/stubs/pika/pika/channel.pyi +++ b/stubs/pika/pika/channel.pyi @@ -1,8 +1,8 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from collections.abc import Callable from logging import Logger from typing import Any -from typing_extensions import Final, Self +from typing_extensions import Final from .callback import CallbackManager from .connection import Connection @@ -25,7 +25,7 @@ class Channel: connection: Connection flow_active: bool - def __init__(self, connection: Connection, channel_number: int, on_open_callback: Callable[[Self], object]) -> None: ... + def __init__(self: Self, connection: Connection, channel_number: int, on_open_callback: Callable[[Self], object]) -> None: ... def __int__(self) -> int: ... def add_callback(self, callback, replies, one_shot: bool = ...) -> None: ... def add_on_cancel_callback(self, callback) -> None: ... diff --git a/stubs/pika/pika/connection.pyi b/stubs/pika/pika/connection.pyi index 21024b427b72..97a10c698fa8 100644 --- a/stubs/pika/pika/connection.pyi +++ b/stubs/pika/pika/connection.pyi @@ -1,8 +1,8 @@ import abc -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from collections.abc import Callable from logging import Logger -from typing_extensions import Final, Self +from typing_extensions import Final from .callback import CallbackManager from .channel import Channel @@ -150,21 +150,23 @@ class Connection(AbstractBase, metaclass=abc.ABCMeta): server_properties: Incomplete known_hosts: Incomplete def __init__( - self, + self: Self, parameters: Parameters | None = ..., on_open_callback: Callable[[Self], object] | None = ..., on_open_error_callback: Callable[[Self, BaseException], object] | None = ..., on_close_callback: Callable[[Self, BaseException], object] | None = ..., internal_connection_workflow: bool = ..., ) -> None: ... - def add_on_close_callback(self, callback: Callable[[Self, BaseException], object]) -> None: ... - def add_on_connection_blocked_callback(self, callback: Callable[[Self, Method[SpecConnection.Blocked]], object]) -> None: ... + def add_on_close_callback(self: Self, callback: Callable[[Self, BaseException], object]) -> None: ... + def add_on_connection_blocked_callback( + self: Self, callback: Callable[[Self, Method[SpecConnection.Blocked]], object] + ) -> None: ... def add_on_connection_unblocked_callback( - self, callback: Callable[[Self, Method[SpecConnection.Unblocked]], object] + self: Self, callback: Callable[[Self, Method[SpecConnection.Unblocked]], object] ) -> None: ... - def add_on_open_callback(self, callback: Callable[[Self], object]) -> None: ... + def add_on_open_callback(self: Self, callback: Callable[[Self], object]) -> None: ... def add_on_open_error_callback( - self, callback: Callable[[Self, BaseException], object], remove_default: bool = ... + self: Self, callback: Callable[[Self, BaseException], object], remove_default: bool = ... ) -> None: ... def channel( self, channel_number: int | None = ..., on_open_callback: Callable[[Channel], object] | None = ... diff --git a/stubs/pika/pika/spec.pyi b/stubs/pika/pika/spec.pyi index c213867c06e6..d0b6bf1227c8 100644 --- a/stubs/pika/pika/spec.pyi +++ b/stubs/pika/pika/spec.pyi @@ -1,6 +1,6 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from typing import ClassVar -from typing_extensions import Literal, Self, TypeAlias +from typing_extensions import Literal, TypeAlias from .amqp_object import Class, Method, Properties @@ -339,7 +339,7 @@ class Exchange(Class): def __init__(self) -> None: ... @property def synchronous(self) -> Literal[False]: ... - def decode(self, encoded: bytes, offset: int = ...) -> Self: ... + def decode(self: Self, encoded: bytes, offset: int = ...) -> Self: ... def encode(self) -> list[bytes]: ... class Delete(Method): @@ -450,7 +450,7 @@ class Queue(Class): ) -> None: ... @property def synchronous(self) -> Literal[True]: ... - def decode(self, encoded: bytes, offset: int = ...) -> Self: ... + def decode(self: Self, encoded: bytes, offset: int = ...) -> Self: ... def encode(self) -> list[bytes]: ... class DeclareOk(Method): @@ -461,7 +461,7 @@ class Queue(Class): def __init__(self, queue: _str, message_count: int, consumer_count: int) -> None: ... @property def synchronous(self) -> Literal[False]: ... - def decode(self, encoded: bytes, offset: int = ...) -> Self: ... + def decode(self: Self, encoded: bytes, offset: int = ...) -> Self: ... def encode(self) -> list[bytes]: ... class Bind(Method):