From ccde5ce04818c1e678ff46f701203cd5322f2683 Mon Sep 17 00:00:00 2001 From: Bao Trinh Date: Tue, 1 Mar 2022 08:03:55 -0600 Subject: [PATCH] Avoid AnyStr except as generic type parameter --- pika-stubs/adapters/blocking_connection.pyi | 3 +-- pika-stubs/adapters/twisted_connection.pyi | 3 +-- pika-stubs/channel.pyi | 3 +-- pika-stubs/compat.pyi | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pika-stubs/adapters/blocking_connection.pyi b/pika-stubs/adapters/blocking_connection.pyi index e48c239..f2a5523 100644 --- a/pika-stubs/adapters/blocking_connection.pyi +++ b/pika-stubs/adapters/blocking_connection.pyi @@ -4,7 +4,6 @@ import types from collections.abc import Mapping from collections.abc import Sequence from typing import Any -from typing import AnyStr from typing import Callable from typing import Iterator from typing import Type @@ -124,7 +123,7 @@ class BlockingChannel: self, queue: str, auto_ack: bool = ... ) -> tuple[spec.Basic.GetOk, spec.BasicProperties, str] | tuple[None, None, None]: ... def basic_publish( - self, exchange: str, routing_key: str, body: AnyStr, properties: spec.BasicProperties | None = ..., mandatory: bool = ... + self, exchange: str, routing_key: str, body: str | bytes, properties: spec.BasicProperties | None = ..., mandatory: bool = ... ) -> None: ... def basic_qos(self, prefetch_size: int = ..., prefetch_count: int = ..., global_qos: bool = ...) -> None: ... def basic_recover(self, requeue: bool = ...) -> None: ... diff --git a/pika-stubs/adapters/twisted_connection.pyi b/pika-stubs/adapters/twisted_connection.pyi index 8e80a3d..fca4f55 100644 --- a/pika-stubs/adapters/twisted_connection.pyi +++ b/pika-stubs/adapters/twisted_connection.pyi @@ -3,7 +3,6 @@ from __future__ import annotations from collections.abc import Mapping from collections.abc import Sequence from typing import Any -from typing import AnyStr from typing import Callable from typing import NamedTuple from typing import TypeVar @@ -77,7 +76,7 @@ class TwistedChannel: def basic_get(self, queue: str, auto_ack: bool = ...) -> Deferred[ReceivedMessage]: ... def basic_nack(self, delivery_tag: int | None = ..., multiple: bool = ..., requeue: bool = ...) -> None: ... def basic_publish( - self, exchange: str, routing_key: str, body: AnyStr, properties: spec.BasicProperties | None = ..., mandatory: bool = ... + self, exchange: str, routing_key: str, body: str | bytes, properties: spec.BasicProperties | None = ..., mandatory: bool = ... ) -> Deferred[None]: ... def basic_qos( self, prefetch_size: int = ..., prefetch_count: int = ..., global_qos: bool = ... diff --git a/pika-stubs/channel.pyi b/pika-stubs/channel.pyi index f6485f5..7dd4c46 100644 --- a/pika-stubs/channel.pyi +++ b/pika-stubs/channel.pyi @@ -3,7 +3,6 @@ from __future__ import annotations from collections.abc import Mapping from collections.abc import Sequence from typing import Any -from typing import AnyStr from typing import Callable from typing import TypeVar from typing_extensions import Literal @@ -74,7 +73,7 @@ class Channel: def basic_get(self, queue: str, callback: _OnBasicGetCallback, auto_ack: bool = ...) -> None: ... def basic_nack(self, delivery_tag: int = ..., multiple: bool = ..., requeue: bool = ...) -> None: ... def basic_publish( - self, exchange: str, routing_key: str, body: AnyStr, properties: spec.BasicProperties | None = ..., mandatory: bool = ... + self, exchange: str, routing_key: str, body: str | bytes, properties: spec.BasicProperties | None = ..., mandatory: bool = ... ) -> None: ... def basic_qos( self, diff --git a/pika-stubs/compat.pyi b/pika-stubs/compat.pyi index db65a37..0bafeec 100644 --- a/pika-stubs/compat.pyi +++ b/pika-stubs/compat.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import abc import re from typing import Any -from typing import AnyStr from typing import ItemsView from typing import KeysView from typing import Type @@ -45,7 +44,7 @@ class long(int): def canonical_str(value: Any) -> str: ... def is_integer(value: Any) -> bool: ... -def as_bytes(value: AnyStr) -> bytes: ... +def as_bytes(value: str | bytes) -> bytes: ... def to_digit(value: str) -> int: ... def get_linux_version(release_str: str) -> tuple[int, int, int]: ...