From 59abef02ec173eec230752254a01de927a039ab3 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Thu, 23 Jul 2026 21:24:29 +0400 Subject: [PATCH 1/2] [pika] Complete merging stubs --- pyrightconfig.stricter.json | 5 +- stubs/pika/@tests/stubtest_allowlist.txt | 3 + stubs/pika/pika/adapters/base_connection.pyi | 6 +- .../pika/pika/adapters/twisted_connection.pyi | 2 +- stubs/pika/pika/amqp_object.pyi | 2 +- stubs/pika/pika/callback.pyi | 46 +- stubs/pika/pika/channel.pyi | 36 +- stubs/pika/pika/connection.pyi | 88 ++-- stubs/pika/pika/data.pyi | 4 +- stubs/pika/pika/frame.pyi | 10 +- stubs/pika/pika/heartbeat.pyi | 8 +- stubs/pika/pika/spec.pyi | 486 ++++++++++-------- stubs/pika/pika/validators.pyi | 7 +- 13 files changed, 384 insertions(+), 319 deletions(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index dd89cb5616a7..5cd12e0013b6 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -73,7 +73,10 @@ "stubs/parsimonious/parsimonious/nodes.pyi", "stubs/peewee", "stubs/pexpect", - "stubs/pika", + "stubs/pika/pika/adapters/twisted_connection.pyi", + "stubs/pika/pika/adapters/utils/connection_workflow.pyi", + "stubs/pika/pika/callback.pyi", + "stubs/pika/pika/channel.pyi", "stubs/pony", "stubs/protobuf", "stubs/psutil/psutil/__init__.pyi", diff --git a/stubs/pika/@tests/stubtest_allowlist.txt b/stubs/pika/@tests/stubtest_allowlist.txt index 218eda692ae1..260f43d685f2 100644 --- a/stubs/pika/@tests/stubtest_allowlist.txt +++ b/stubs/pika/@tests/stubtest_allowlist.txt @@ -1,3 +1,6 @@ +# bytes alias for Python 3 compatibility +pika.spec.str + # Behind a TYPE_CHECKING guard at runtime. pika.adapters.select_connection.SELECT_ERROR_T pika.adapters.select_connection.POLLER_PARAMS diff --git a/stubs/pika/pika/adapters/base_connection.pyi b/stubs/pika/pika/adapters/base_connection.pyi index 3e7e4866b60f..ab9b4dc94ac1 100644 --- a/stubs/pika/pika/adapters/base_connection.pyi +++ b/stubs/pika/pika/adapters/base_connection.pyi @@ -1,6 +1,6 @@ import abc from _typeshed import Incomplete -from collections.abc import Callable, Mapping, Sequence +from collections.abc import Callable, Sequence from logging import Logger from typing import Final, Generic, Literal, TypeVar from typing_extensions import Self @@ -62,8 +62,8 @@ class _StreamingProtocolShim(AbstractStreamProtocol, Generic[_IOLoop]): connection_state: Literal[0, 1, 2, 3, 4, 5, 6] # one of the constants above params: Parameters callbacks: CallbackManager - server_capabilities: Mapping[str, bool] | None - server_properties: Mapping[str, Incomplete] | None + server_capabilities: dict[str, bool] | None + server_properties: dict[str, Incomplete] | None known_hosts: str | 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: ... diff --git a/stubs/pika/pika/adapters/twisted_connection.pyi b/stubs/pika/pika/adapters/twisted_connection.pyi index 8b629dc7016d..204fc2d61603 100644 --- a/stubs/pika/pika/adapters/twisted_connection.pyi +++ b/stubs/pika/pika/adapters/twisted_connection.pyi @@ -138,7 +138,7 @@ class _TwistedConnectionAdapter(Connection): self, parameters: Parameters | None, on_open_callback: Callable[[Connection], object] | None, - on_open_error_callback: Callable[[Connection, Exception], object] | None, + on_open_error_callback: Callable[[Connection, BaseException], object] | None, on_close_callback: Callable[[Connection, Exception], object] | None, custom_reactor: ReactorBase | None = None, ) -> None: ... diff --git a/stubs/pika/pika/amqp_object.pyi b/stubs/pika/pika/amqp_object.pyi index 9f412173e43a..744c8dd1da57 100644 --- a/stubs/pika/pika/amqp_object.pyi +++ b/stubs/pika/pika/amqp_object.pyi @@ -3,7 +3,7 @@ from typing import ClassVar class AMQPObject: NAME: ClassVar[str] INDEX: ClassVar[int | None] - def __eq__(self, other: AMQPObject | None) -> bool: ... # type: ignore[override] + def __eq__(self, other: object) -> bool: ... class Class(AMQPObject): ... diff --git a/stubs/pika/pika/callback.pyi b/stubs/pika/pika/callback.pyi index c5fe764fafce..852fc1643dc5 100644 --- a/stubs/pika/pika/callback.pyi +++ b/stubs/pika/pika/callback.pyi @@ -1,24 +1,27 @@ -from collections.abc import Callable +from _typeshed import Incomplete +from collections.abc import Callable, Mapping from logging import Logger -from typing import Literal, TypeAlias +from typing import Any, Final, Literal, ParamSpec, TypeAlias, TypeVar from .amqp_object import AMQPObject +_P = ParamSpec("_P") +_R = TypeVar("_R") AMQPValue: TypeAlias = type[AMQPObject] | AMQPObject | int | str LOGGER: Logger def name_or_value(value: AMQPValue) -> str: ... -def sanitize_prefix(function): ... -def check_for_prefix_and_key(function): ... +def sanitize_prefix(function: Callable[_P, _R]) -> Callable[_P, _R]: ... +def check_for_prefix_and_key(function: Callable[_P, _R]) -> Callable[_P, _R | Literal[False]]: ... class CallbackManager: - CALLS: str - ARGUMENTS: str - DUPLICATE_WARNING: str - CALLBACK: str - ONE_SHOT: str - ONLY_CALLER: str + CALLS: Final = "calls" + ARGUMENTS: Final = "arguments" + DUPLICATE_WARNING: Final = 'Duplicate callback found for "%s:%s"' + CALLBACK: Final = "callback" + ONE_SHOT: Final = "one_shot" + ONLY_CALLER: Final = "only" def __init__(self) -> None: ... def add( self, @@ -28,13 +31,24 @@ class CallbackManager: callback: Callable[..., object], one_shot: bool = True, only_caller: object | None = None, - arguments=None, + arguments: Mapping[str, Incomplete] | None = None, ) -> tuple[str | int, str | object]: ... def clear(self) -> None: ... def cleanup(self, prefix: str | int) -> bool: ... - def pending(self, prefix: str | int, key: str | object) -> int | None: ... - def process(self, prefix: str | int, key: AMQPValue, caller, *args, **keywords) -> bool: ... + def pending(self, prefix: str | int, key: AMQPValue) -> int | None: ... + def process( + self, + prefix: str | int, + key: AMQPValue, + caller, + *args: Any, # Arguments depends on callbacks stored on self._stack + **keywords: Any, + ) -> bool: ... def remove( - self, prefix: str | int, key: AMQPValue, callback_value: Callable[..., object] | None = None, arguments=None - ) -> Literal[True]: ... - def remove_all(self, prefix: str | int, key: AMQPValue) -> None: ... + self, + prefix: str | int, + key: AMQPValue, + callback_value: Callable[..., object] | None = None, + arguments: Mapping[str, Incomplete] | None = None, + ) -> bool: ... + def remove_all(self, prefix: str | int, key: AMQPValue) -> Literal[False] | None: ... diff --git a/stubs/pika/pika/channel.pyi b/stubs/pika/pika/channel.pyi index c0252bbb65a8..7fdbbd93d7b6 100644 --- a/stubs/pika/pika/channel.pyi +++ b/stubs/pika/pika/channel.pyi @@ -1,18 +1,20 @@ from _typeshed import Incomplete -from collections.abc import Callable +from collections.abc import Callable, Iterable, Mapping from logging import Logger -from typing import Any, Final +from typing import Final, TypeVar from typing_extensions import Self +from . import amqp_object from .callback import CallbackManager from .connection import Connection -from .data import _ArgumentMapping from .exchange_type import ExchangeType from .frame import Body, Header, Method from .spec import Basic, BasicProperties, Confirm, Exchange, Queue, Tx +_Method = TypeVar("_Method", bound=amqp_object.Method) + LOGGER: Logger -MAX_CHANNELS: Final[int] +MAX_CHANNELS: Final = 65535 class Channel: CLOSED: Final = 0 @@ -27,11 +29,11 @@ class Channel: def __init__(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 = True) -> None: ... - def add_on_cancel_callback(self, callback) -> None: ... - def add_on_close_callback(self, callback) -> None: ... - def add_on_flow_callback(self, callback) -> None: ... - def add_on_return_callback(self, callback) -> None: ... + def add_callback(self, callback: Callable[..., object], replies: Iterable[Incomplete], one_shot: bool = True) -> None: ... + def add_on_cancel_callback(self, callback: Callable[[Method[Basic.Cancel]], object]) -> None: ... + def add_on_close_callback(self, callback: Callable[[Channel, Exception], object]) -> None: ... + def add_on_flow_callback(self, callback: Callable[[bool], object]) -> None: ... + def add_on_return_callback(self, callback: Callable[[Channel, Basic.Return, BasicProperties, bytes], object]) -> None: ... def basic_ack(self, delivery_tag: int = 0, multiple: bool = False) -> None: ... def basic_cancel( self, consumer_tag: str = "", callback: Callable[[Method[Basic.CancelOk]], object] | None = None @@ -43,7 +45,7 @@ class Channel: auto_ack: bool = False, exclusive: bool = False, consumer_tag: str | None = None, - arguments: _ArgumentMapping | None = None, + arguments: Mapping[str, Incomplete] | None = None, callback: Callable[[Method[Basic.ConsumeOk]], object] | None = None, ) -> str: ... def basic_get( @@ -82,7 +84,7 @@ class Channel: destination: str, source: str, routing_key: str = "", - arguments: _ArgumentMapping | None = None, + arguments: Mapping[str, Incomplete] | None = None, callback: Callable[[Method[Exchange.BindOk]], object] | None = None, ) -> None: ... def exchange_declare( @@ -93,7 +95,7 @@ class Channel: durable: bool = False, auto_delete: bool = False, internal: bool = False, - arguments: _ArgumentMapping | None = None, + arguments: Mapping[str, Incomplete] | None = None, callback: Callable[[Method[Exchange.DeclareOk]], object] | None = None, ) -> None: ... def exchange_delete( @@ -107,7 +109,7 @@ class Channel: destination: str | None = None, source: str | None = None, routing_key: str = "", - arguments: _ArgumentMapping | None = None, + arguments: Mapping[str, Incomplete] | None = None, callback: Callable[[Method[Exchange.UnbindOk]], object] | None = None, ) -> None: ... def flow(self, active: bool, callback: Callable[[bool], object] | None = None) -> None: ... @@ -125,7 +127,7 @@ class Channel: queue: str, exchange: str, routing_key: str | None = None, - arguments: _ArgumentMapping | None = None, + arguments: Mapping[str, Incomplete] | None = None, callback: Callable[[Method[Queue.BindOk]], object] | None = None, ) -> None: ... def queue_declare( @@ -135,7 +137,7 @@ class Channel: durable: bool = False, exclusive: bool = False, auto_delete: bool = False, - arguments: _ArgumentMapping | None = None, + arguments: Mapping[str, Incomplete] | None = None, callback: Callable[[Method[Queue.DeclareOk]], object] | None = None, ) -> None: ... def queue_delete( @@ -151,7 +153,7 @@ class Channel: queue: str, exchange: str | None = None, routing_key: str | None = None, - arguments: _ArgumentMapping | None = None, + arguments: Mapping[str, Incomplete] | None = None, callback: Callable[[Method[Queue.UnbindOk]], object] | None = None, ): ... def tx_commit(self, callback: Callable[[Method[Tx.CommitOk]], object] | None = None) -> None: ... @@ -160,4 +162,4 @@ class Channel: class ContentFrameAssembler: def __init__(self) -> None: ... - def process(self, frame_value: Method[Any] | Header | Body) -> tuple[Incomplete, Incomplete, bytes] | None: ... + def process(self, frame_value: Method[_Method] | Header | Body) -> tuple[Method[_Method], Header, bytes] | None: ... diff --git a/stubs/pika/pika/connection.pyi b/stubs/pika/pika/connection.pyi index 99eace9f7218..0264ccc017e0 100644 --- a/stubs/pika/pika/connection.pyi +++ b/stubs/pika/pika/connection.pyi @@ -3,17 +3,17 @@ import ssl from _typeshed import Incomplete from collections.abc import Callable from logging import Logger -from typing import Final +from typing import Final, Literal from typing_extensions import Self from .callback import CallbackManager from .channel import Channel from .compat import AbstractBase -from .credentials import _Credentials +from .credentials import PlainCredentials, _Credentials from .frame import Method from .spec import Connection as SpecConnection -PRODUCT: str +PRODUCT: Final = "Pika Python Client Library" LOGGER: Logger class Parameters: @@ -35,26 +35,26 @@ class Parameters: "_virtual_host", "_tcp_options", ) - DEFAULT_USERNAME: str - DEFAULT_PASSWORD: str - DEFAULT_BLOCKED_CONNECTION_TIMEOUT: None - DEFAULT_CHANNEL_MAX: int - DEFAULT_CLIENT_PROPERTIES: None - DEFAULT_CREDENTIALS: Incomplete - DEFAULT_CONNECTION_ATTEMPTS: int - DEFAULT_FRAME_MAX: int + DEFAULT_USERNAME: Final = "guest" + DEFAULT_PASSWORD: Final = "guest" + DEFAULT_BLOCKED_CONNECTION_TIMEOUT: Final = None + DEFAULT_CHANNEL_MAX: Final = 65535 + DEFAULT_CLIENT_PROPERTIES: Final = None + DEFAULT_CREDENTIALS: Final[PlainCredentials] + DEFAULT_CONNECTION_ATTEMPTS: Final = 1 + DEFAULT_FRAME_MAX: Final = 131072 DEFAULT_HEARTBEAT_TIMEOUT: None - DEFAULT_HOST: str - DEFAULT_LOCALE: str - DEFAULT_PORT: int - DEFAULT_RETRY_DELAY: float - DEFAULT_SOCKET_TIMEOUT: float - DEFAULT_STACK_TIMEOUT: float - DEFAULT_SSL: bool - DEFAULT_SSL_OPTIONS: None - DEFAULT_SSL_PORT: int - DEFAULT_VIRTUAL_HOST: str - DEFAULT_TCP_OPTIONS: None + DEFAULT_HOST: Final = "localhost" + DEFAULT_LOCALE: Final = "en_US" + DEFAULT_PORT: Final = 5672 + DEFAULT_RETRY_DELAY: Final = 2.0 + DEFAULT_SOCKET_TIMEOUT: Final = 10.0 + DEFAULT_STACK_TIMEOUT: Final = 15.0 + DEFAULT_SSL: Final = False + DEFAULT_SSL_OPTIONS: Final = None + DEFAULT_SSL_PORT: Final = 5671 + DEFAULT_VIRTUAL_HOST: Final = "/" + DEFAULT_TCP_OPTIONS: Final = None def __init__(self) -> None: ... def __eq__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... @@ -135,13 +135,12 @@ class Parameters: def virtual_host(self, value: str) -> None: ... @property - def tcp_options(self) -> dict[Incomplete, Incomplete] | None: ... + def tcp_options(self) -> dict[str, Incomplete] | None: ... @tcp_options.setter - def tcp_options(self, value: dict[Incomplete, Incomplete] | None) -> None: ... + def tcp_options(self, value: dict[str, Incomplete] | None) -> None: ... class ConnectionParameters(Parameters): __slots__ = () - def __init__( self, host: str = ..., @@ -158,8 +157,8 @@ class ConnectionParameters(Parameters): stack_timeout: float | None = ..., locale: str = ..., blocked_connection_timeout: float | None = ..., - client_properties: dict[Incomplete, Incomplete] | None = ..., - tcp_options: dict[Incomplete, Incomplete] | None = ..., + client_properties: dict[str, Incomplete] | None = ..., + tcp_options: dict[str, Incomplete] | None = ..., ) -> None: ... class URLParameters(Parameters): @@ -173,22 +172,22 @@ class SSLOptions: def __init__(self, context: ssl.SSLContext, server_hostname: str | None = None) -> None: ... class Connection(AbstractBase, metaclass=abc.ABCMeta): - ON_CONNECTION_CLOSED: Final[str] - ON_CONNECTION_ERROR: Final[str] - ON_CONNECTION_OPEN_OK: Final[str] - CONNECTION_CLOSED: Final[int] - CONNECTION_INIT: Final[int] - CONNECTION_PROTOCOL: Final[int] - CONNECTION_START: Final[int] - CONNECTION_TUNE: Final[int] - CONNECTION_OPEN: Final[int] - CONNECTION_CLOSING: Final[int] - connection_state: int # one of the constants above + ON_CONNECTION_CLOSED: Final = "_on_connection_closed" + ON_CONNECTION_ERROR: Final = "_on_connection_error" + ON_CONNECTION_OPEN_OK: Final = "_on_connection_open_ok" + CONNECTION_CLOSED: Final = 0 + CONNECTION_INIT: Final = 1 + CONNECTION_PROTOCOL: Final = 2 + CONNECTION_START: Final = 3 + CONNECTION_TUNE: Final = 4 + CONNECTION_OPEN: Final = 5 + CONNECTION_CLOSING: Final = 6 + connection_state: Literal[0, 1, 2, 3, 4, 5, 6] # one of the constants above params: Parameters callbacks: CallbackManager - server_capabilities: Incomplete - server_properties: Incomplete - known_hosts: Incomplete + server_capabilities: dict[str, bool] | None + server_properties: dict[str, Incomplete] | None + known_hosts: str | None def __init__( self, parameters: Parameters | None = None, @@ -209,7 +208,12 @@ class Connection(AbstractBase, metaclass=abc.ABCMeta): def channel( self, channel_number: int | None = None, on_open_callback: Callable[[Channel], object] | None = None ) -> Channel: ... - def update_secret(self, new_secret, reason, callback=None) -> None: ... + def update_secret( + self, + new_secret: str | bytes, + reason: str | bytes, + callback: Callable[[Method[SpecConnection.UpdateSecretOk]], object] | None = None, + ) -> None: ... def close(self, reply_code: int = 200, reply_text: str = "Normal shutdown") -> None: ... @property def is_closed(self) -> bool: ... diff --git a/stubs/pika/pika/data.pyi b/stubs/pika/pika/data.pyi index 3e3b289c22a4..18ad67c71a6b 100644 --- a/stubs/pika/pika/data.pyi +++ b/stubs/pika/pika/data.pyi @@ -7,8 +7,8 @@ _Value: TypeAlias = str | bytes | bool | int | Decimal | datetime | _ArgumentMap _ArgumentMapping: TypeAlias = Mapping[str, _Value] def encode_short_string(pieces: list[bytes], value: str | bytes) -> int: ... -def decode_short_string(encoded: bytes, offset: int) -> tuple[str, int]: ... +def decode_short_string(encoded: bytes, offset: int) -> tuple[str | bytes, int]: ... def encode_table(pieces: list[bytes], table: _ArgumentMapping) -> int: ... def encode_value(pieces: list[bytes], value: _Value) -> int: ... -def decode_table(encoded: bytes, offset: int) -> tuple[dict[str, _Value], int]: ... +def decode_table(encoded: bytes, offset: int) -> tuple[dict[str | bytes, _Value], int]: ... def decode_value(encoded: bytes, offset: int) -> tuple[_Value, int]: ... diff --git a/stubs/pika/pika/frame.pyi b/stubs/pika/pika/frame.pyi index f0019be803bf..8b547d8478ee 100644 --- a/stubs/pika/pika/frame.pyi +++ b/stubs/pika/pika/frame.pyi @@ -2,14 +2,14 @@ from abc import abstractmethod from logging import Logger from typing import Generic, TypeVar -from .amqp_object import AMQPObject, Method as AMQPMethod +from . import amqp_object from .spec import BasicProperties -_M = TypeVar("_M", bound=AMQPMethod) +_M = TypeVar("_M", bound=amqp_object.Method) LOGGER: Logger -class Frame(AMQPObject): +class Frame(amqp_object.AMQPObject): frame_type: int channel_number: int def __init__(self, frame_type: int, channel_number: int) -> None: ... @@ -36,7 +36,7 @@ class Heartbeat(Frame): def __init__(self) -> None: ... def marshal(self) -> bytes: ... -class ProtocolHeader(AMQPObject): +class ProtocolHeader(amqp_object.AMQPObject): frame_type: int major: int minor: int @@ -44,4 +44,4 @@ class ProtocolHeader(AMQPObject): def __init__(self, major: int | None = None, minor: int | None = None, revision: int | None = None) -> None: ... def marshal(self) -> bytes: ... -def decode_frame(data_in: bytes) -> tuple[int, Frame | None]: ... +def decode_frame(data_in: bytes) -> tuple[int, Frame | ProtocolHeader | None]: ... diff --git a/stubs/pika/pika/heartbeat.pyi b/stubs/pika/pika/heartbeat.pyi index 757fb6246551..1c6ec89dfc60 100644 --- a/stubs/pika/pika/heartbeat.pyi +++ b/stubs/pika/pika/heartbeat.pyi @@ -1,12 +1,14 @@ from logging import Logger +from pika.connection import Connection + LOGGER: Logger class HeartbeatChecker: - def __init__(self, connection, timeout) -> None: ... + def __init__(self, connection: Connection, timeout: float) -> None: ... @property - def bytes_received_on_connection(self): ... + def bytes_received_on_connection(self) -> int: ... @property - def connection_is_idle(self): ... + def connection_is_idle(self) -> bool: ... def received(self) -> None: ... def stop(self) -> None: ... diff --git a/stubs/pika/pika/spec.pyi b/stubs/pika/pika/spec.pyi index 8ce6fb2e2adb..eee768972a16 100644 --- a/stubs/pika/pika/spec.pyi +++ b/stubs/pika/pika/spec.pyi @@ -1,52 +1,45 @@ -import builtins from _typeshed import Incomplete +from builtins import type as _type from collections.abc import Mapping -from datetime import datetime -from decimal import Decimal -from typing import ClassVar, Final, Literal, TypeAlias +from typing import ClassVar, Final, Literal from typing_extensions import Self from pika.amqp_object import Class, Method, Properties +from pika.data import _ArgumentMapping from pika.delivery_mode import DeliveryMode -# Ouch. Since str = bytes at runtime, we need a type alias for "str". -_str: TypeAlias = builtins.str # noqa: Y042 -_Value: TypeAlias = _str | bytes | bool | int | Decimal | datetime | _ArgumentMapping | list[_Value] | None -_ArgumentMapping: TypeAlias = Mapping[_str, _Value] -str = builtins.bytes - PROTOCOL_VERSION: Final[tuple[int, int, int]] -PORT: Final[int] -ACCESS_REFUSED: Final[int] -CHANNEL_ERROR: Final[int] -COMMAND_INVALID: Final[int] -CONNECTION_FORCED: Final[int] -CONTENT_TOO_LARGE: Final[int] -FRAME_BODY: Final[int] -FRAME_END: Final[int] -FRAME_END_SIZE: Final[int] -FRAME_ERROR: Final[int] -FRAME_HEADER: Final[int] -FRAME_HEADER_SIZE: Final[int] -FRAME_HEARTBEAT: Final[int] -FRAME_MAX_SIZE: Final[int] -FRAME_METHOD: Final[int] -FRAME_MIN_SIZE: Final[int] -INTERNAL_ERROR: Final[int] -INVALID_PATH: Final[int] -NOT_ALLOWED: Final[int] -NOT_FOUND: Final[int] -NOT_IMPLEMENTED: Final[int] -NO_CONSUMERS: Final[int] -NO_ROUTE: Final[int] -PERSISTENT_DELIVERY_MODE: Final[int] -PRECONDITION_FAILED: Final[int] -REPLY_SUCCESS: Final[int] -RESOURCE_ERROR: Final[int] -RESOURCE_LOCKED: Final[int] -SYNTAX_ERROR: Final[int] -TRANSIENT_DELIVERY_MODE: Final[int] -UNEXPECTED_FRAME: Final[int] +PORT: Final = 5672 +ACCESS_REFUSED: Final = 403 +CHANNEL_ERROR: Final = 504 +COMMAND_INVALID: Final = 503 +CONNECTION_FORCED: Final = 320 +CONTENT_TOO_LARGE: Final = 311 +FRAME_BODY: Final = 3 +FRAME_END: Final = 206 +FRAME_END_SIZE: Final = 1 +FRAME_ERROR: Final = 501 +FRAME_HEADER: Final = 2 +FRAME_HEADER_SIZE: Final = 7 +FRAME_HEARTBEAT: Final = 8 +FRAME_MAX_SIZE: Final = 131072 +FRAME_METHOD: Final = 1 +FRAME_MIN_SIZE: Final = 4096 +INTERNAL_ERROR: Final = 541 +INVALID_PATH: Final = 402 +NOT_ALLOWED: Final = 530 +NOT_FOUND: Final = 404 +NOT_IMPLEMENTED: Final = 540 +NO_CONSUMERS: Final = 313 +NO_ROUTE: Final = 312 +PERSISTENT_DELIVERY_MODE: Final = 2 +PRECONDITION_FAILED: Final = 406 +REPLY_SUCCESS: Final = 200 +RESOURCE_ERROR: Final = 506 +RESOURCE_LOCKED: Final = 405 +SYNTAX_ERROR: Final = 502 +TRANSIENT_DELIVERY_MODE: Final = 1 +UNEXPECTED_FRAME: Final = 505 class Connection(Class): INDEX: ClassVar[int] @@ -56,15 +49,15 @@ class Connection(Class): version_major: int version_minor: int server_properties: _ArgumentMapping | None - mechanisms: _str - locales: _str + mechanisms: str + locales: str def __init__( self, version_major: int = 0, version_minor: int = 9, server_properties: _ArgumentMapping | None = None, - mechanisms: _str = "PLAIN", - locales: _str = "en_US", + mechanisms: str = "PLAIN", + locales: str = "en_US", ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -74,15 +67,15 @@ class Connection(Class): class StartOk(Method): INDEX: ClassVar[int] client_properties: _ArgumentMapping | None - mechanism: _str - response: _str | None - locale: _str + mechanism: str + response: str | None + locale: str def __init__( self, client_properties: _ArgumentMapping | None = None, - mechanism: _str = "PLAIN", - response: _str | None = None, - locale: _str = "en_US", + mechanism: str = "PLAIN", + response: str | None = None, + locale: str = "en_US", ) -> None: ... @property def synchronous(self) -> Literal[False]: ... @@ -91,8 +84,8 @@ class Connection(Class): class Secure(Method): INDEX: ClassVar[int] - challenge: _str | None - def __init__(self, challenge: _str | None = None) -> None: ... + challenge: str | None + def __init__(self, challenge: str | None = None) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -100,8 +93,8 @@ class Connection(Class): class SecureOk(Method): INDEX: ClassVar[int] - response: _str - def __init__(self, response: _str | None = None) -> None: ... + response: str + def __init__(self, response: str | None = None) -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -131,10 +124,10 @@ class Connection(Class): class Open(Method): INDEX: ClassVar[int] - virtual_host: _str - capabilities: _str + virtual_host: str + capabilities: str insist: bool - def __init__(self, virtual_host: _str = "/", capabilities: _str = "", insist: bool = False) -> None: ... + def __init__(self, virtual_host: str = "/", capabilities: str = "", insist: bool = False) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -142,8 +135,8 @@ class Connection(Class): class OpenOk(Method): INDEX: ClassVar[int] - known_hosts: _str - def __init__(self, known_hosts: _str = "") -> None: ... + known_hosts: str + def __init__(self, known_hosts: str = "") -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -151,11 +144,13 @@ class Connection(Class): class Close(Method): INDEX: ClassVar[int] - reply_code: Incomplete - reply_text: Incomplete - class_id: Incomplete - method_id: Incomplete - def __init__(self, reply_code=None, reply_text: _str = "", class_id=None, method_id=None) -> None: ... + reply_code: int | None + reply_text: str + class_id: int | None + method_id: int | None + def __init__( + self, reply_code: int | None = None, reply_text: str = "", class_id: int | None = None, method_id: int | None = None + ) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -171,8 +166,8 @@ class Connection(Class): class Blocked(Method): INDEX: ClassVar[int] - reason: Incomplete - def __init__(self, reason: _str = "") -> None: ... + reason: str + def __init__(self, reason: str = "") -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -188,10 +183,10 @@ class Connection(Class): class UpdateSecret(Method): INDEX: ClassVar[int] - new_secret: Incomplete - reason: Incomplete - mechanisms: _str - def __init__(self, new_secret, reason) -> None: ... + new_secret: str + reason: str + mechanisms: str + def __init__(self, new_secret: str, reason: str) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -210,8 +205,8 @@ class Channel(Class): class Open(Method): INDEX: ClassVar[int] - out_of_band: _str - def __init__(self, out_of_band: _str = "") -> None: ... + out_of_band: str + def __init__(self, out_of_band: str = "") -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -219,8 +214,8 @@ class Channel(Class): class OpenOk(Method): INDEX: ClassVar[int] - channel_id: _str - def __init__(self, channel_id: _str = "") -> None: ... + channel_id: str + def __init__(self, channel_id: str = "") -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -246,11 +241,13 @@ class Channel(Class): class Close(Method): INDEX: ClassVar[int] - reply_code: Incomplete - reply_text: Incomplete - class_id: Incomplete - method_id: Incomplete - def __init__(self, reply_code=None, reply_text: _str = "", class_id=None, method_id=None) -> None: ... + reply_code: int | None + reply_text: str + class_id: int | None + method_id: int | None + def __init__( + self, reply_code: int | None = None, reply_text: str = "", class_id: int | None = None, method_id: int | None = None + ) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -269,7 +266,7 @@ class Access(Class): class Request(Method): INDEX: ClassVar[int] - realm: _str + realm: str exclusive: bool passive: bool active: bool @@ -277,7 +274,7 @@ class Access(Class): read: bool def __init__( self, - realm: _str = "/data", + realm: str = "/data", exclusive: bool = False, passive: bool = True, active: bool = True, @@ -291,7 +288,7 @@ class Access(Class): class RequestOk(Method): INDEX: ClassVar[int] - ticket: Incomplete + ticket: int def __init__(self, ticket: int = 1) -> None: ... @property def synchronous(self) -> Literal[False]: ... @@ -303,26 +300,26 @@ class Exchange(Class): class Declare(Method): INDEX: ClassVar[int] - ticket: Incomplete - exchange: Incomplete - type: Incomplete + ticket: int + exchange: str | None + type: str passive: bool durable: bool auto_delete: bool internal: bool nowait: bool - arguments: Incomplete + arguments: Mapping[str, Incomplete] | None def __init__( self, ticket: int = 0, - exchange=None, - type=..., + exchange: str | None = None, + type: str = ..., passive: bool = False, durable: bool = False, auto_delete: bool = False, internal: bool = False, nowait: bool = False, - arguments=None, + arguments: Mapping[str, Incomplete] | None = None, ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -339,11 +336,13 @@ class Exchange(Class): class Delete(Method): INDEX: ClassVar[int] - ticket: Incomplete - exchange: Incomplete - if_unused: Incomplete + ticket: int + exchange: str | None + if_unused: bool nowait: bool - def __init__(self, ticket: int = 0, exchange=None, if_unused: bool = False, nowait: bool = False) -> None: ... + def __init__( + self, ticket: int = 0, exchange: str | None = None, if_unused: bool = False, nowait: bool = False + ) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -360,13 +359,19 @@ class Exchange(Class): class Bind(Method): INDEX: ClassVar[int] ticket: int - destination: Incomplete | None - source: Incomplete | None - routing_key: _str + destination: str | None + source: str | None + routing_key: str nowait: bool - arguments: Incomplete | None + arguments: Mapping[str, Incomplete] | None def __init__( - self, ticket: int = 0, destination=None, source=None, routing_key: _str = "", nowait: bool = False, arguments=None + self, + ticket: int = 0, + destination: str | None = None, + source: str | None = None, + routing_key: str = "", + nowait: bool = False, + arguments: Mapping[str, Incomplete] | None = None, ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -383,14 +388,20 @@ class Exchange(Class): class Unbind(Method): INDEX: ClassVar[int] - ticket: Incomplete - destination: Incomplete - source: Incomplete - routing_key: Incomplete + ticket: int + destination: str | None + source: str | None + routing_key: str nowait: bool - arguments: Incomplete + arguments: Mapping[str, Incomplete] | None def __init__( - self, ticket: int = 0, destination=None, source=None, routing_key: _str = "", nowait: bool = False, arguments=None + self, + ticket: int = 0, + destination: str | None = None, + source: str | None = None, + routing_key: str = "", + nowait: bool = False, + arguments: Mapping[str, Incomplete] | None = None, ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -410,24 +421,24 @@ class Queue(Class): class Declare(Method): INDEX: ClassVar[int] - ticket: Incomplete - queue: Incomplete + ticket: int + queue: str passive: bool durable: bool exclusive: bool auto_delete: bool nowait: bool - arguments: Incomplete + arguments: Mapping[str, Incomplete] | None def __init__( self, ticket: int = 0, - queue: _str = "", + queue: str = "", passive: bool = False, durable: bool = False, exclusive: bool = False, auto_delete: bool = False, nowait: bool = False, - arguments=None, + arguments: Mapping[str, Incomplete] | None = None, ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -436,10 +447,10 @@ class Queue(Class): class DeclareOk(Method): INDEX: ClassVar[int] - queue: _str + queue: str message_count: int consumer_count: int - def __init__(self, queue: _str, message_count: int, consumer_count: int) -> None: ... + 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 = 0) -> Self: ... @@ -447,14 +458,20 @@ class Queue(Class): class Bind(Method): INDEX: ClassVar[int] - ticket: Incomplete - queue: Incomplete - exchange: Incomplete - routing_key: Incomplete + ticket: int + queue: str + exchange: str | None + routing_key: str nowait: bool - arguments: Incomplete + arguments: Mapping[str, Incomplete] | None def __init__( - self, ticket: int = 0, queue: _str = "", exchange=None, routing_key: _str = "", nowait: bool = False, arguments=None + self, + ticket: int = 0, + queue: str = "", + exchange: str | None = None, + routing_key: str = "", + nowait: bool = False, + arguments: Mapping[str, Incomplete] | None = None, ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -471,10 +488,10 @@ class Queue(Class): class Purge(Method): INDEX: ClassVar[int] - ticket: Incomplete - queue: Incomplete + ticket: int + queue: str nowait: bool - def __init__(self, ticket: int = 0, queue: _str = "", nowait: bool = False) -> None: ... + def __init__(self, ticket: int = 0, queue: str = "", nowait: bool = False) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -482,8 +499,8 @@ class Queue(Class): class PurgeOk(Method): INDEX: ClassVar[int] - message_count: Incomplete - def __init__(self, message_count=None) -> None: ... + message_count: int | None + def __init__(self, message_count: int | None = None) -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -491,13 +508,13 @@ class Queue(Class): class Delete(Method): INDEX: ClassVar[int] - ticket: Incomplete - queue: Incomplete - if_unused: Incomplete - if_empty: Incomplete + ticket: int + queue: str + if_unused: bool + if_empty: bool nowait: bool def __init__( - self, ticket: int = 0, queue: _str = "", if_unused: bool = False, if_empty: bool = False, nowait: bool = False + self, ticket: int = 0, queue: str = "", if_unused: bool = False, if_empty: bool = False, nowait: bool = False ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -506,8 +523,8 @@ class Queue(Class): class DeleteOk(Method): INDEX: ClassVar[int] - message_count: Incomplete - def __init__(self, message_count=None) -> None: ... + message_count: int | None + def __init__(self, message_count: int | None = None) -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -515,12 +532,19 @@ class Queue(Class): class Unbind(Method): INDEX: ClassVar[int] - ticket: Incomplete - queue: Incomplete - exchange: Incomplete - routing_key: Incomplete - arguments: Incomplete - def __init__(self, ticket: int = 0, queue: _str = "", exchange=None, routing_key: _str = "", arguments=None) -> None: ... + ticket: int + queue: str + exchange: str | None + routing_key: str + arguments: Mapping[str, Incomplete] | None + def __init__( + self, + ticket: int = 0, + queue: str = "", + exchange: str | None = None, + routing_key: str = "", + arguments: Mapping[str, Incomplete] | None = None, + ) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -539,9 +563,9 @@ class Basic(Class): class Qos(Method): INDEX: ClassVar[int] - prefetch_size: Incomplete - prefetch_count: Incomplete - global_qos: Incomplete + prefetch_size: int + prefetch_count: int + global_qos: bool def __init__(self, prefetch_size: int = 0, prefetch_count: int = 0, global_qos: bool = False) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -558,24 +582,24 @@ class Basic(Class): class Consume(Method): INDEX: ClassVar[int] - ticket: Incomplete - queue: Incomplete - consumer_tag: Incomplete + ticket: int + queue: str + consumer_tag: str no_local: bool no_ack: bool exclusive: bool nowait: bool - arguments: Incomplete + arguments: Mapping[str, Incomplete] | None def __init__( self, ticket: int = 0, - queue: _str = "", - consumer_tag: _str = "", + queue: str = "", + consumer_tag: str = "", no_local: bool = False, no_ack: bool = False, exclusive: bool = False, nowait: bool = False, - arguments=None, + arguments: Mapping[str, Incomplete] | None = None, ) -> None: ... @property def synchronous(self) -> Literal[True]: ... @@ -584,8 +608,8 @@ class Basic(Class): class ConsumeOk(Method): INDEX: ClassVar[int] - consumer_tag: Incomplete - def __init__(self, consumer_tag=None) -> None: ... + consumer_tag: str | None + def __init__(self, consumer_tag: str | None = None) -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -593,9 +617,9 @@ class Basic(Class): class Cancel(Method): INDEX: ClassVar[int] - consumer_tag: Incomplete + consumer_tag: str | None nowait: bool - def __init__(self, consumer_tag=None, nowait: bool = False) -> None: ... + def __init__(self, consumer_tag: str | None = None, nowait: bool = False) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -603,8 +627,8 @@ class Basic(Class): class CancelOk(Method): INDEX: ClassVar[int] - consumer_tag: Incomplete - def __init__(self, consumer_tag=None) -> None: ... + consumer_tag: str | None + def __init__(self, consumer_tag: str | None = None) -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -612,13 +636,13 @@ class Basic(Class): class Publish(Method): INDEX: ClassVar[int] - ticket: Incomplete - exchange: Incomplete - routing_key: Incomplete - mandatory: Incomplete - immediate: Incomplete + ticket: int + exchange: str + routing_key: str + mandatory: bool + immediate: bool def __init__( - self, ticket: int = 0, exchange: _str = "", routing_key: _str = "", mandatory: bool = False, immediate: bool = False + self, ticket: int = 0, exchange: str = "", routing_key: str = "", mandatory: bool = False, immediate: bool = False ) -> None: ... @property def synchronous(self) -> Literal[False]: ... @@ -627,11 +651,13 @@ class Basic(Class): class Return(Method): INDEX: ClassVar[int] - reply_code: Incomplete - reply_text: Incomplete - exchange: Incomplete - routing_key: Incomplete - def __init__(self, reply_code=None, reply_text: _str = "", exchange=None, routing_key=None) -> None: ... + reply_code: int | None + reply_text: str + exchange: str | None + routing_key: str | None + def __init__( + self, reply_code: int | None = None, reply_text: str = "", exchange: str | None = None, routing_key: str | None = None + ) -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -639,13 +665,18 @@ class Basic(Class): class Deliver(Method): INDEX: ClassVar[int] - consumer_tag: Incomplete - delivery_tag: Incomplete - redelivered: Incomplete - exchange: Incomplete - routing_key: Incomplete + consumer_tag: str | None + delivery_tag: int | None + redelivered: bool + exchange: str | None + routing_key: str | None def __init__( - self, consumer_tag=None, delivery_tag=None, redelivered: bool = False, exchange=None, routing_key=None + self, + consumer_tag: str | None = None, + delivery_tag: int | None = None, + redelivered: bool = False, + exchange: str | None = None, + routing_key: str | None = None, ) -> None: ... @property def synchronous(self) -> Literal[False]: ... @@ -654,10 +685,10 @@ class Basic(Class): class Get(Method): INDEX: ClassVar[int] - ticket: Incomplete - queue: Incomplete + ticket: int + queue: str no_ack: bool - def __init__(self, ticket: int = 0, queue: _str = "", no_ack: bool = False) -> None: ... + def __init__(self, ticket: int = 0, queue: str = "", no_ack: bool = False) -> None: ... @property def synchronous(self) -> Literal[True]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -665,13 +696,18 @@ class Basic(Class): class GetOk(Method): INDEX: ClassVar[int] - delivery_tag: Incomplete - redelivered: Incomplete - exchange: Incomplete - routing_key: Incomplete - message_count: Incomplete + delivery_tag: int | None + redelivered: bool + exchange: str | None + routing_key: str | None + message_count: int | None def __init__( - self, delivery_tag=None, redelivered: bool = False, exchange=None, routing_key=None, message_count=None + self, + delivery_tag: int | None = None, + redelivered: bool = False, + exchange: str | None = None, + routing_key: str | None = None, + message_count: int | None = None, ) -> None: ... @property def synchronous(self) -> Literal[False]: ... @@ -680,8 +716,8 @@ class Basic(Class): class GetEmpty(Method): INDEX: ClassVar[int] - cluster_id: Incomplete - def __init__(self, cluster_id: _str = "") -> None: ... + cluster_id: str + def __init__(self, cluster_id: str = "") -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -689,8 +725,8 @@ class Basic(Class): class Ack(Method): INDEX: ClassVar[int] - delivery_tag: Incomplete - multiple: Incomplete + delivery_tag: int + multiple: bool def __init__(self, delivery_tag: int = 0, multiple: bool = False) -> None: ... @property def synchronous(self) -> Literal[False]: ... @@ -699,9 +735,9 @@ class Basic(Class): class Reject(Method): INDEX: ClassVar[int] - delivery_tag: Incomplete + delivery_tag: int | None requeue: bool - def __init__(self, delivery_tag=None, requeue: bool = True) -> None: ... + def __init__(self, delivery_tag: int | None = None, requeue: bool = True) -> None: ... @property def synchronous(self) -> Literal[False]: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... @@ -735,8 +771,8 @@ class Basic(Class): class Nack(Method): INDEX: ClassVar[int] - delivery_tag: Incomplete - multiple: Incomplete + delivery_tag: int + multiple: bool requeue: bool def __init__(self, delivery_tag: int = 0, multiple: bool = False, requeue: bool = True) -> None: ... @property @@ -816,52 +852,52 @@ class Confirm(Class): def encode(self) -> list[bytes]: ... class BasicProperties(Properties): - CLASS: ClassVar[builtins.type[Basic]] + CLASS: ClassVar[_type[Basic]] INDEX: ClassVar[int] - FLAG_CONTENT_TYPE: ClassVar[int] - FLAG_CONTENT_ENCODING: ClassVar[int] - FLAG_HEADERS: ClassVar[int] - FLAG_DELIVERY_MODE: ClassVar[int] - FLAG_PRIORITY: ClassVar[int] - FLAG_CORRELATION_ID: ClassVar[int] - FLAG_REPLY_TO: ClassVar[int] - FLAG_EXPIRATION: ClassVar[int] - FLAG_MESSAGE_ID: ClassVar[int] - FLAG_TIMESTAMP: ClassVar[int] - FLAG_TYPE: ClassVar[int] - FLAG_USER_ID: ClassVar[int] - FLAG_APP_ID: ClassVar[int] - FLAG_CLUSTER_ID: ClassVar[int] - content_type: _str | None - content_encoding: _str | None + FLAG_CONTENT_TYPE: Final = 32768 + FLAG_CONTENT_ENCODING: Final = 16384 + FLAG_HEADERS: Final = 8192 + FLAG_DELIVERY_MODE: Final = 4096 + FLAG_PRIORITY: Final = 2048 + FLAG_CORRELATION_ID: Final = 1024 + FLAG_REPLY_TO: Final = 512 + FLAG_EXPIRATION: Final = 256 + FLAG_MESSAGE_ID: Final = 128 + FLAG_TIMESTAMP: Final = 64 + FLAG_TYPE: Final = 32 + FLAG_USER_ID: Final = 16 + FLAG_APP_ID: Final = 8 + FLAG_CLUSTER_ID: Final = 4 + content_type: str | None + content_encoding: str | None headers: _ArgumentMapping | None delivery_mode: Literal[1, 2] | None - priority: Incomplete - correlation_id: _str | None - reply_to: _str | None - expiration: _str | None - message_id: _str | None - timestamp: Incomplete - type: _str | None - user_id: _str | None - app_id: _str | None - cluster_id: _str | None + priority: int | None + correlation_id: str | None + reply_to: str | None + expiration: str | None + message_id: str | None + timestamp: int | None + type: str | None + user_id: str | None + app_id: str | None + cluster_id: str | None def __init__( self, - content_type: _str | None = None, - content_encoding: _str | None = None, + content_type: str | None = None, + content_encoding: str | None = None, headers: _ArgumentMapping | None = None, delivery_mode: DeliveryMode | Literal[1, 2] | None = None, - priority=None, - correlation_id: _str | None = None, - reply_to: _str | None = None, - expiration: _str | None = None, - message_id: _str | None = None, - timestamp=None, - type: _str | None = None, - user_id: _str | None = None, - app_id: _str | None = None, - cluster_id: _str | None = None, + priority: int | None = None, + correlation_id: str | None = None, + reply_to: str | None = None, + expiration: str | None = None, + message_id: str | None = None, + timestamp: int | None = None, + type: str | None = None, + user_id: str | None = None, + app_id: str | None = None, + cluster_id: str | None = None, ) -> None: ... def decode(self, encoded: bytes, offset: int = 0) -> Self: ... def encode(self) -> list[bytes]: ... diff --git a/stubs/pika/pika/validators.pyi b/stubs/pika/pika/validators.pyi index 8fea4a8e7343..07c2bb0f110d 100644 --- a/stubs/pika/pika/validators.pyi +++ b/stubs/pika/pika/validators.pyi @@ -1,14 +1,15 @@ +from _typeshed import ConvertibleToInt from collections.abc import Callable from typing import Literal, overload def require_string(value: object, value_name: str) -> None: ... # raise TypeError if value is not string def require_callback( - callback: object, callback_name: str = "callback" -) -> None: ... # raise TypeError if callback is not callable + callback: object, callback_name: str = "callback" # raise TypeError if callback is not callable +) -> None: ... @overload def rpc_completion_callback(callback: None) -> Literal[True]: ... @overload def rpc_completion_callback(callback: Callable[..., object]) -> Literal[False]: ... -def zero_or_greater(name: str, value: str | float) -> None: ... +def zero_or_greater(name: str, value: ConvertibleToInt) -> None: ... From ccb93ec669d456b23cb0e13eed98cdabfac02b1d Mon Sep 17 00:00:00 2001 From: donbarbos Date: Fri, 24 Jul 2026 11:50:12 +0400 Subject: [PATCH 2/2] revert __eq__ changes --- stubs/pika/pika/amqp_object.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pika/pika/amqp_object.pyi b/stubs/pika/pika/amqp_object.pyi index 744c8dd1da57..9f412173e43a 100644 --- a/stubs/pika/pika/amqp_object.pyi +++ b/stubs/pika/pika/amqp_object.pyi @@ -3,7 +3,7 @@ from typing import ClassVar class AMQPObject: NAME: ClassVar[str] INDEX: ClassVar[int | None] - def __eq__(self, other: object) -> bool: ... + def __eq__(self, other: AMQPObject | None) -> bool: ... # type: ignore[override] class Class(AMQPObject): ...