diff --git a/.flake8 b/.flake8 index 47f4fc5..480f13d 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,30 @@ +# The following rules are incompatible with or enforced by black: +# E203 whitespace before ':' -- scripts only +# E301 expected 1 blank line -- stubs only +# E302 expected 2 blank lines -- stubs only +# E305 expected 2 blank lines -- stubs only +# E501 line too long + +# Some rules are considered irrelevant to stub files: +# E701 multiple statements on one line (colon) -- disallows "..." on the same line +# F401 imported but unused -- does not recognize re-exports +# https://github.com/PyCQA/pyflakes/issues/474 +# F822 undefined name in __all__ -- flake8 does not recognize 'foo: Any' +# https://github.com/PyCQA/pyflakes/issues/533 + +# Rules that are out of the control of stub authors: +# E741 ambiguous variable name +# F403 import *' used; unable to detect undefined names +# F405 defined from star imports + [flake8] -max-line-length = 99 +per-file-ignores = + *.py: E203, E501 + *.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822 + typing.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822 + exclude = .venv, + .idea, + .mypy_cache, .git diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index da7b799..370ac6d 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -4,29 +4,35 @@ on: [push, pull_request] jobs: check: + name: Run tests runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10"] steps: + - uses: actions/checkout@v2 - - uses: actions/checkout@v2 - - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Perform checks - run: | - python -m pip install --upgrade pip - pip install -e .[dev] - flake8 pika-stubs - mypy -p pika-stubs --strict + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements-dev.txt' + + - name: Update pip + run: python -m pip install -U pip + + - name: Install dependencies + run: pip install -r requirements-dev.txt .[dev] + + - name: Lint with flake8 + run: flake8 + + - name: Check stub files with mypy + run: mypy --strict -p pika-stubs + + - name: Stubtest + run: stubtest --concise pika diff --git a/mypy.ini b/mypy.ini index 3f4ca54..2fa095a 100644 --- a/mypy.ini +++ b/mypy.ini @@ -8,5 +8,7 @@ warn_unused_ignores = True warn_unused_configs = True warn_unreachable = True +show_error_codes = True + files = pika-stubs diff --git a/pika-stubs/__init__.pyi b/pika-stubs/__init__.pyi index 628dba4..e1bf725 100644 --- a/pika-stubs/__init__.pyi +++ b/pika-stubs/__init__.pyi @@ -1,12 +1,10 @@ -from .connection import ConnectionParameters as ConnectionParameters -from .connection import SSLOptions as SSLOptions -from .connection import URLParameters as URLParameters -from .credentials import PlainCredentials as PlainCredentials -from .spec import BasicProperties as BasicProperties - from . import adapters from .adapters import BaseConnection as BaseConnection from .adapters import BlockingConnection as BlockingConnection from .adapters import SelectConnection as SelectConnection - from .adapters.utils.connection_workflow import AMQPConnectionWorkflow as AMQPConnectionWorkflow +from .connection import ConnectionParameters as ConnectionParameters +from .connection import SSLOptions as SSLOptions +from .connection import URLParameters as URLParameters +from .credentials import PlainCredentials as PlainCredentials +from .spec import BasicProperties as BasicProperties diff --git a/pika-stubs/adapters/__init__.pyi b/pika-stubs/adapters/__init__.pyi index bd64ca1..1cb978e 100644 --- a/pika-stubs/adapters/__init__.pyi +++ b/pika-stubs/adapters/__init__.pyi @@ -1,3 +1,4 @@ -from .base_connection import BaseConnection as BaseConnection # noqa: F401 -from .blocking_connection import BlockingConnection as BlockingConnection # noqa: F401 -from .select_connection import IOLoop as IOLoop, SelectConnection as SelectConnection # noqa: F401 +from .base_connection import BaseConnection as BaseConnection +from .blocking_connection import BlockingConnection as BlockingConnection +from .select_connection import IOLoop as IOLoop +from .select_connection import SelectConnection as SelectConnection diff --git a/pika-stubs/adapters/asyncio_connection.pyi b/pika-stubs/adapters/asyncio_connection.pyi index ba5243e..8f23d8c 100644 --- a/pika-stubs/adapters/asyncio_connection.pyi +++ b/pika-stubs/adapters/asyncio_connection.pyi @@ -1,41 +1,39 @@ +from __future__ import annotations + import asyncio -from typing import Callable, Optional, Sequence, Union +from collections.abc import Sequence +from typing import Callable from .. import connection from . import base_connection from .utils import connection_workflow -_OnCloseCallback = Callable[['AsyncioConnection', Exception], None] -_OnOpenCallback = Callable[['AsyncioConnection'], None] -_OnOpenErrorCallback = Callable[['AsyncioConnection', Union[str, Exception]], None] - +_OnCloseCallback = Callable[[AsyncioConnection, Exception], None] +_OnOpenCallback = Callable[[AsyncioConnection], None] +_OnOpenErrorCallback = Callable[[AsyncioConnection, str | Exception], None] class AsyncioConnection(base_connection.BaseConnection[asyncio.AbstractEventLoop]): - def __init__( self, - parameters: Optional[connection.Parameters] = None, - on_open_callback: Optional[_OnOpenCallback] = None, - on_open_error_callback: Optional[_OnOpenErrorCallback] = None, - on_close_callback: Optional[_OnCloseCallback] = None, - custom_ioloop: Optional[asyncio.AbstractEventLoop] = None, + parameters: connection.Parameters | None = ..., + on_open_callback: _OnOpenCallback | None = ..., + on_open_error_callback: _OnOpenErrorCallback | None = ..., + on_close_callback: _OnCloseCallback | None = ..., + custom_ioloop: asyncio.AbstractEventLoop | None = ..., internal_connection_workflow: bool = ..., ) -> None: ... - @classmethod def create_connection( cls, connection_configs: Sequence[connection.Parameters], on_done: Callable[ [ - Union[ - connection.Connection, - connection_workflow.AMQPConnectionWorkflowFailed, - connection_workflow.AMQPConnectionWorkflowAborted, - ], + connection.Connection + | connection_workflow.AMQPConnectionWorkflowFailed + | connection_workflow.AMQPConnectionWorkflowAborted ], - None + None, ], - custom_ioloop: Optional[asyncio.AbstractEventLoop] = ..., - workflow: Optional[connection_workflow.AbstractAMQPConnectionWorkflow] = ..., + custom_ioloop: asyncio.AbstractEventLoop | None = ..., + workflow: connection_workflow.AbstractAMQPConnectionWorkflow | None = ..., ) -> connection_workflow.AbstractAMQPConnectionWorkflow: ... diff --git a/pika-stubs/adapters/base_connection.pyi b/pika-stubs/adapters/base_connection.pyi index 7fc423e..94dc5e2 100644 --- a/pika-stubs/adapters/base_connection.pyi +++ b/pika-stubs/adapters/base_connection.pyi @@ -1,28 +1,31 @@ +from __future__ import annotations + import abc -from typing import Callable, Generic, Optional, Sequence, TypeVar, Union +from collections.abc import Sequence +from typing import Callable +from typing import Generic +from typing import TypeVar from .. import connection -from .utils import connection_workflow, nbio_interface - -_OnCloseCallback = Callable[['BaseConnection', Exception], None] -_OnOpenCallback = Callable[['BaseConnection'], None] -_OnOpenErrorCallback = Callable[['BaseConnection', Union[str, Exception]], None] +from .utils import connection_workflow +from .utils import nbio_interface -_IOLoop = TypeVar('_IOLoop') +_OnCloseCallback = Callable[[BaseConnection, Exception], None] +_OnOpenCallback = Callable[[BaseConnection], None] +_OnOpenErrorCallback = Callable[[BaseConnection, str | Exception], None] +_IOLoop = TypeVar("_IOLoop") class BaseConnection(Generic[_IOLoop], connection.Connection): - def __init__( self, - parameters: Optional[connection.Parameters], - on_open_callback: Optional[_OnOpenCallback], - on_open_error_callback: Optional[_OnOpenErrorCallback], - on_close_callback: Optional[_OnCloseCallback], + parameters: connection.Parameters | None, + on_open_callback: _OnOpenCallback | None, + on_open_error_callback: _OnOpenErrorCallback | None, + on_close_callback: _OnCloseCallback | None, nbio: nbio_interface.AbstractIOServices, internal_connection_workflow: bool, ) -> None: ... - @classmethod @abc.abstractmethod def create_connection( @@ -30,17 +33,14 @@ class BaseConnection(Generic[_IOLoop], connection.Connection): connection_configs: Sequence[connection.Parameters], on_done: Callable[ [ - Union[ - connection.Connection, - connection_workflow.AMQPConnectionWorkflowFailed, - connection_workflow.AMQPConnectionWorkflowAborted, - ], + connection.Connection + | connection_workflow.AMQPConnectionWorkflowFailed + | connection_workflow.AMQPConnectionWorkflowAborted ], - None + None, ], - custom_ioloop: Optional[_IOLoop] = ..., - workflow: Optional[connection_workflow.AbstractAMQPConnectionWorkflow] = ..., + custom_ioloop: _IOLoop | None = ..., + workflow: connection_workflow.AbstractAMQPConnectionWorkflow | None = ..., ) -> connection_workflow.AbstractAMQPConnectionWorkflow: ... - @property def ioloop(self) -> _IOLoop: ... diff --git a/pika-stubs/adapters/blocking_connection.pyi b/pika-stubs/adapters/blocking_connection.pyi index c1a2ba4..9499b05 100644 --- a/pika-stubs/adapters/blocking_connection.pyi +++ b/pika-stubs/adapters/blocking_connection.pyi @@ -1,52 +1,37 @@ from __future__ import annotations import types -from typing import Any, Callable, Iterator, List, Mapping, Optional, Tuple, Type, Union, Sequence - -from .. import channel, connection, frame, spec +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 + +from .. import channel +from .. import connection +from .. import frame +from .. import spec from ..exchange_type import ExchangeType - class BlockingConnection: - def __init__( - self, - parameters: connection.Parameters | Sequence[connection.Parameters] | None = ..., - _impl_class: Optional[Any] = ..., + self, parameters: connection.Parameters | Sequence[connection.Parameters] | None = ..., _impl_class: Any | None = ... ) -> None: ... - def __enter__(self) -> BlockingConnection: ... - def __exit__( - self, - exc_type: Optional[Type[BaseException]], - value: Optional[BaseException], - traceback: Optional[types.TracebackType], - ) -> None: ... - - def add_on_connection_blocked_callback( - self, - callback: Callable[[spec.Connection.Blocked], None], + self, exc_type: Type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None ) -> None: ... - - def add_on_connection_unblocked_callback( - self, - callback: Callable[[spec.Connection.Unblocked], None], - ) -> None: ... - - def call_later( - self, - delay: float, - callback: Callable[[], None], - ) -> object: ... - + def add_on_connection_blocked_callback(self, callback: Callable[[spec.Connection.Blocked], None]) -> None: ... + def add_on_connection_unblocked_callback(self, callback: Callable[[spec.Connection.Unblocked], None]) -> None: ... + def call_later(self, delay: float, callback: Callable[[], None]) -> object: ... def add_callback_threadsafe(self, callback: Callable[[], None]) -> None: ... def remove_timeout(self, timeout_id: object) -> None: ... def close(self, reply_code: int = ..., reply_text: str = ...) -> None: ... def process_data_events(self, time_limit: int = ...) -> None: ... def sleep(self, duration: float) -> None: ... - def channel(self, channel_number: Optional[int] = ...) -> BlockingChannel: ... - + def channel(self, channel_number: int | None = ...) -> BlockingChannel: ... @property def is_closed(self) -> bool: ... @property @@ -59,7 +44,6 @@ class BlockingConnection: def exchange_exchange_bindings_supported(self) -> bool: ... @property def publisher_confirms_supported(self) -> bool: ... - # Legacy property names for backward compatibility @property def basic_nack(self) -> bool: ... @@ -70,36 +54,20 @@ class BlockingConnection: @property def publisher_confirms(self) -> bool: ... - class ReturnedMessage: method: spec.Basic.Return = ... properties: spec.BasicProperties = ... body: bytes = ... - - def __init__( - self, - method: spec.Basic.Return, - properties: spec.BasicProperties, - body: bytes, - ) -> None: ... - + def __init__(self, method: spec.Basic.Return, properties: spec.BasicProperties, body: bytes) -> None: ... class BlockingChannel: - def __init__(self, channel_impl: channel.Channel, connection: BlockingConnection) -> None: ... - def __int__(self) -> int: ... - def __enter__(self) -> BlockingChannel: ... - def __exit__( - self, - exc_type: Optional[Type[BaseException]], - value: Optional[BaseException], - traceback: Optional[types.TracebackType], + self, exc_type: Type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None ) -> None: ... - @property def channel_number(self) -> int: ... @property @@ -109,100 +77,45 @@ class BlockingChannel: @property def is_open(self) -> bool: ... @property - def consumer_tags(self) -> List[str]: ... - + def consumer_tags(self) -> list[str]: ... def close(self, reply_code: int = ..., reply_text: str = ...) -> None: ... def flow(self, active: bool) -> bool: ... - def add_on_cancel_callback(self, callback: Callable[[spec.Basic.Cancel], None]) -> None: ... def add_on_return_callback(self, callback: Callable[[spec.Basic.Return], None]) -> None: ... - def basic_consume( self, queue: Any, - on_message_callback: Callable[ - [ - BlockingChannel, - spec.Basic.Deliver, - spec.BasicProperties, - bytes, - ], - None, - ], + on_message_callback: Callable[[BlockingChannel, spec.Basic.Deliver, spec.BasicProperties, bytes], None], auto_ack: bool = ..., exclusive: bool = ..., - consumer_tag: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., + consumer_tag: str | None = ..., + arguments: Mapping[str, Any] | None = ..., ) -> str: ... - - def basic_cancel(self, consumer_tag: str) -> List[ - Tuple[spec.Basic.Deliver, spec.BasicProperties, bytes], - ]: ... + def basic_cancel(self, consumer_tag: str) -> list[tuple[spec.Basic.Deliver, spec.BasicProperties, bytes]]: ... def start_consuming(self) -> None: ... - def stop_consuming(self, consumer_tag: Optional[str] = ...) -> None: ... - + def stop_consuming(self, consumer_tag: str | None = ...) -> None: ... def consume( self, queue: str, auto_ack: bool = ..., exclusive: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., - inactivity_timeout: Optional[float] = ..., - ) -> Iterator[ - Union[ - Tuple[ - spec.Basic.Deliver, - spec.BasicProperties, - bytes, - ], - Tuple[ - None, - None, - None, - ], - ] - ]: ... - + arguments: Mapping[str, Any] | None = ..., + inactivity_timeout: float | None = ..., + ) -> Iterator[tuple[spec.Basic.Deliver, spec.BasicProperties, bytes] | tuple[None, None, None]]: ... def get_waiting_message_count(self) -> int: ... - def cancel(self) -> int: ... - def basic_ack(self, delivery_tag: int = ..., multiple: bool = ...) -> None: ... - - def basic_nack( - self, - delivery_tag: Optional[int] = ..., - multiple: bool = ..., - requeue: bool = ..., - ) -> None: ... - - def basic_get(self, queue: str, auto_ack: bool = ...) -> Tuple[ - Optional[spec.Basic.GetOk], - Optional[spec.BasicProperties], - Optional[str], - ]: ... - + def basic_nack(self, delivery_tag: int | None = ..., multiple: bool = ..., requeue: bool = ...) -> None: ... + def basic_get( + self, queue: str, auto_ack: bool = ... + ) -> tuple[spec.Basic.GetOk | None, spec.BasicProperties | None, str | None]: ... def basic_publish( - self, - exchange: str, - routing_key: str, - body: bytes | str, - properties: Optional[spec.BasicProperties] = ..., - mandatory: bool = ..., + self, exchange: str, routing_key: str, body: AnyStr, properties: spec.BasicProperties | None = ..., mandatory: bool = ... ) -> None: ... - - def basic_qos( - self, - prefetch_size: int = ..., - prefetch_count: int = ..., - global_qos: bool = ..., - ) -> None: ... - + def basic_qos(self, prefetch_size: int = ..., prefetch_count: int = ..., global_qos: bool = ...) -> None: ... def basic_recover(self, requeue: bool = ...) -> None: ... - def basic_reject(self, delivery_tag: Optional[int] = ..., requeue: bool = ...) -> None: ... - + def basic_reject(self, delivery_tag: int | None = ..., requeue: bool = ...) -> None: ... def confirm_delivery(self) -> None: ... - def exchange_declare( self, exchange: str, @@ -211,31 +124,19 @@ class BlockingChannel: durable: bool = ..., auto_delete: bool = ..., internal: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> frame.Method[spec.Exchange.DeclareOk]: ... - - def exchange_delete( - self, - exchange: Optional[str] = ..., - if_unused: bool = ..., - ) -> frame.Method[spec.Exchange.DeleteOk]: ... - + def exchange_delete(self, exchange: str | None = ..., if_unused: bool = ...) -> frame.Method[spec.Exchange.DeleteOk]: ... def exchange_bind( - self, - destination: str, - source: str, - routing_key: str = ..., - arguments: Optional[Mapping[str, Any]] = ..., + self, destination: str, source: str, routing_key: str = ..., arguments: Mapping[str, Any] | None = ... ) -> frame.Method[spec.Exchange.BindOk]: ... - def exchange_unbind( self, - destination: Optional[str] = ..., - source: Optional[str] = ..., + destination: str | None = ..., + source: str | None = ..., routing_key: str = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> frame.Method[spec.Exchange.UnbindOk]: ... - def queue_declare( self, queue: str, @@ -243,34 +144,16 @@ class BlockingChannel: durable: bool = ..., exclusive: bool = ..., auto_delete: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> frame.Method[spec.Queue.DeclareOk]: ... - - def queue_delete( - self, - queue: str, - if_unused: bool = ..., - if_empty: bool = ..., - ) -> frame.Method[spec.Queue.DeleteOk]: ... - + def queue_delete(self, queue: str, if_unused: bool = ..., if_empty: bool = ...) -> frame.Method[spec.Queue.DeleteOk]: ... def queue_purge(self, queue: str) -> frame.Method[spec.Queue.PurgeOk]: ... - def queue_bind( - self, - queue: str, - exchange: str, - routing_key: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., + self, queue: str, exchange: str, routing_key: str | None = ..., arguments: Mapping[str, Any] | None = ... ) -> frame.Method[spec.Queue.BindOk]: ... - def queue_unbind( - self, - queue: Any, - exchange: Optional[str] = ..., - routing_key: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., + self, queue: Any, exchange: str | None = ..., routing_key: str | None = ..., arguments: Mapping[str, Any] | None = ... ) -> frame.Method[spec.Queue.UnbindOk]: ... - def tx_select(self) -> frame.Method[spec.Tx.SelectOk]: ... def tx_commit(self) -> frame.Method[spec.Tx.CommitOk]: ... def tx_rollback(self) -> frame.Method[spec.Tx.CommitOk]: ... diff --git a/pika-stubs/adapters/select_connection.pyi b/pika-stubs/adapters/select_connection.pyi index 3418a59..0678536 100644 --- a/pika-stubs/adapters/select_connection.pyi +++ b/pika-stubs/adapters/select_connection.pyi @@ -1,62 +1,56 @@ from __future__ import annotations import abc -from typing import Any, AnyStr, Callable, IO, Optional, Sequence, Union - -from .. import compat, connection +from collections.abc import Sequence +from typing import IO +from typing import Any +from typing import AnyStr +from typing import Callable + +from .. import compat +from .. import connection from . import base_connection -from .utils import connection_workflow, nbio_interface, selector_ioloop_adapter +from .utils import connection_workflow +from .utils import nbio_interface +from .utils import selector_ioloop_adapter -SELECT_TYPE: Optional[str] +SELECT_TYPE: str | None _OnCloseCallback = Callable[[base_connection.BaseConnection, Exception], None] _OnOpenCallback = Callable[[base_connection.BaseConnection], None] -_OnOpenErrorCallback = Callable[[base_connection.BaseConnection, Union[str, Exception]], None] - - -class SelectConnection(base_connection.BaseConnection['IOLoop']): +_OnOpenErrorCallback = Callable[[base_connection.BaseConnection, str | Exception], None] +class SelectConnection(base_connection.BaseConnection[IOLoop]): def __init__( self, - parameters: Optional[connection.Parameters] = ..., - on_open_callback: Optional[_OnOpenCallback] = ..., - on_open_error_callback: Optional[_OnOpenErrorCallback] = ..., - on_close_callback: Optional[_OnCloseCallback] = ..., - custom_ioloop: Optional[ - Union[ - IOLoop, - nbio_interface.AbstractIOServices, - ], - ] = ..., + parameters: connection.Parameters | None = ..., + on_open_callback: _OnOpenCallback | None = ..., + on_open_error_callback: _OnOpenErrorCallback | None = ..., + on_close_callback: _OnCloseCallback | None = ..., + custom_ioloop: IOLoop | nbio_interface.AbstractIOServices | None = ..., internal_connection_workflow: bool = ..., ) -> None: ... - @classmethod def create_connection( cls, connection_configs: Sequence[connection.Parameters], on_done: Callable[ [ - Union[ - connection.Connection, - connection_workflow.AMQPConnectionWorkflowFailed, - connection_workflow.AMQPConnectionWorkflowAborted, - ], + connection.Connection + | connection_workflow.AMQPConnectionWorkflowFailed + | connection_workflow.AMQPConnectionWorkflowAborted ], - None + None, ], - custom_ioloop: Optional[IOLoop] = ..., - workflow: Optional[connection_workflow.AbstractAMQPConnectionWorkflow] = ..., + custom_ioloop: IOLoop | None = ..., + workflow: connection_workflow.AbstractAMQPConnectionWorkflow | None = ..., ) -> connection_workflow.AbstractAMQPConnectionWorkflow: ... - class _Timeout: deadline: float = ... callback: Callable[[], None] = ... - def __init__(self, deadline: float, callback: Callable[[], None]) -> None: ... - def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... def __lt__(self, other: Any) -> bool: ... @@ -64,20 +58,17 @@ class _Timeout: def __le__(self, other: Any) -> bool: ... def __ge__(self, other: Any) -> bool: ... - class PollEvents: READ: int = ... WRITE: int = ... ERROR: int = ... - class IOLoop(selector_ioloop_adapter.AbstractSelectorIOLoop[_Timeout]): READ: int = ... WRITE: int = ... ERROR: int = ... - def __init__(self) -> None: ... def close(self) -> None: ... def call_later(self, delay: float, callback: Callable[[], None]) -> _Timeout: ... @@ -85,14 +76,7 @@ class IOLoop(selector_ioloop_adapter.AbstractSelectorIOLoop[_Timeout]): def add_callback_threadsafe(self, callback: Callable[[], None]) -> None: ... def add_callback(self, callback: Callable[[], None]) -> None: ... def process_timeouts(self) -> None: ... - - def add_handler( - self, - fd: IO[AnyStr], - handler: Callable[[IO[AnyStr], int], None], - events: int, - ) -> None: ... - + def add_handler(self, fd: IO[AnyStr], handler: Callable[[IO[AnyStr], int], None], events: int) -> None: ... def update_handler(self, fd: IO[AnyStr], events: int) -> None: ... def remove_handler(self, fd: IO[AnyStr]) -> None: ... def start(self) -> None: ... @@ -101,69 +85,37 @@ class IOLoop(selector_ioloop_adapter.AbstractSelectorIOLoop[_Timeout]): def deactivate_poller(self) -> None: ... def poll(self) -> None: ... - class _PollerBase(compat.AbstractBase): POLL_TIMEOUT_MULT: int = ... - - def __init__( - self, - get_wait_seconds: Callable[[], float], - process_timeouts: Callable[[], None], - ) -> None: ... - + def __init__(self, get_wait_seconds: Callable[[], float], process_timeouts: Callable[[], None]) -> None: ... def close(self) -> None: ... def wake_threadsafe(self) -> None: ... - - def add_handler( - self, - fileno: int, - handler: Callable[[int, int], None], - events: int, - ) -> None: ... - + def add_handler(self, fileno: int, handler: Callable[[int, int], None], events: int) -> None: ... def update_handler(self, fileno: int, events: int) -> None: ... def remove_handler(self, fileno: int) -> None: ... def activate_poller(self) -> None: ... def deactivate_poller(self) -> None: ... def start(self) -> None: ... def stop(self) -> None: ... - @abc.abstractmethod def poll(self) -> None: ... - class SelectPoller(_PollerBase): POLL_TIMEOUT_MULT: int = ... - def poll(self) -> None: ... - class KQueuePoller(_PollerBase): - - def __init__( - self, - get_wait_seconds: Callable[[], float], - process_timeouts: Callable[[], None], - ) -> None: ... - + def __init__(self, get_wait_seconds: Callable[[], float], process_timeouts: Callable[[], None]) -> None: ... def poll(self) -> None: ... - class PollPoller(_PollerBase): POLL_TIMEOUT_MULT: int = ... - - def __init__( - self, - get_wait_seconds: Callable[[], float], - process_timeouts: Callable[[], None], - ) -> None: ... - + def __init__(self, get_wait_seconds: Callable[[], float], process_timeouts: Callable[[], None]) -> None: ... def poll(self) -> None: ... - class EPollPoller(PollPoller): POLL_TIMEOUT_MULT: int = ... diff --git a/pika-stubs/adapters/tornado_connection.pyi b/pika-stubs/adapters/tornado_connection.pyi index 3b4d384..3fd782e 100644 --- a/pika-stubs/adapters/tornado_connection.pyi +++ b/pika-stubs/adapters/tornado_connection.pyi @@ -1,47 +1,41 @@ -from typing import Callable, Optional, Sequence, Union +from __future__ import annotations + +from collections.abc import Sequence +from typing import Callable import tornado.ioloop from .. import connection from . import base_connection -from .utils import connection_workflow, nbio_interface - -_OnCloseCallback = Callable[['TornadoConnection', Exception], None] -_OnOpenCallback = Callable[['TornadoConnection'], None] -_OnOpenErrorCallback = Callable[['TornadoConnection', Union[str, Exception]], None] +from .utils import connection_workflow +from .utils import nbio_interface +_OnCloseCallback = Callable[[TornadoConnection, Exception], None] +_OnOpenCallback = Callable[[TornadoConnection], None] +_OnOpenErrorCallback = Callable[[TornadoConnection, str | Exception], None] class TornadoConnection(base_connection.BaseConnection[tornado.ioloop.IOLoop]): - def __init__( self, - parameters: Optional[connection.Parameters] = None, - on_open_callback: Optional[_OnOpenCallback] = None, - on_open_error_callback: Optional[_OnOpenErrorCallback] = None, - on_close_callback: Optional[_OnCloseCallback] = None, - custom_ioloop: Optional[ - Union[ - tornado.ioloop.IOLoop, - nbio_interface.AbstractIOServices, - ], - ] = None, + parameters: connection.Parameters | None = ..., + on_open_callback: _OnOpenCallback | None = ..., + on_open_error_callback: _OnOpenErrorCallback | None = ..., + on_close_callback: _OnCloseCallback | None = ..., + custom_ioloop: tornado.ioloop.IOLoop | nbio_interface.AbstractIOServices | None = ..., internal_connection_workflow: bool = ..., ) -> None: ... - @classmethod def create_connection( cls, connection_configs: Sequence[connection.Parameters], on_done: Callable[ [ - Union[ - connection.Connection, - connection_workflow.AMQPConnectionWorkflowFailed, - connection_workflow.AMQPConnectionWorkflowAborted, - ], + connection.Connection + | connection_workflow.AMQPConnectionWorkflowFailed + | connection_workflow.AMQPConnectionWorkflowAborted ], - None + None, ], - custom_ioloop: Optional[tornado.ioloop.IOLoop] = ..., - workflow: Optional[connection_workflow.AbstractAMQPConnectionWorkflow] = ..., + custom_ioloop: tornado.ioloop.IOLoop | None = ..., + workflow: connection_workflow.AbstractAMQPConnectionWorkflow | None = ..., ) -> connection_workflow.AbstractAMQPConnectionWorkflow: ... diff --git a/pika-stubs/adapters/twisted_connection.pyi b/pika-stubs/adapters/twisted_connection.pyi index 406400f..8e80a3d 100644 --- a/pika-stubs/adapters/twisted_connection.pyi +++ b/pika-stubs/adapters/twisted_connection.pyi @@ -1,49 +1,38 @@ from __future__ import annotations -from typing import ( - Any, - Callable, - List, - Mapping, - NamedTuple, - Optional, - Sequence, - Union, - TypeVar, - Tuple, -) +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 import twisted.internet.base import twisted.internet.defer import twisted.internet.interfaces import twisted.internet.protocol import twisted.python.failure -from twisted.internet.defer import Deferred, DeferredQueue +from twisted.internet.defer import Deferred +from twisted.internet.defer import DeferredQueue from .. import amqp_object from .. import frame from .. import spec +from ..channel import Channel from ..connection import Connection from ..connection import Parameters -from ..channel import Channel from ..exchange_type import ExchangeType _T = TypeVar("_T") class ClosableDeferredQueue(DeferredQueue[_T]): - closed: Union[twisted.python.failure.Failure, Exception] = ... - - def __init__( - self, - size: Optional[int] = ..., - backlog: Optional[int] = ..., - ) -> None: ... - + closed: twisted.python.failure.Failure | Exception = ... + def __init__(self, size: int | None = ..., backlog: int | None = ...) -> None: ... def put(self, obj: _T) -> None: ... def get(self) -> Deferred[_T]: ... - def close(self, reason: Union[twisted.python.failure.Failure, Exception, str]) -> None: ... - + def close(self, reason: twisted.python.failure.Failure | Exception | str) -> None: ... # Generic [named] tuples aren't supported (https://github.com/python/mypy/issues/685) # so we can't provide more specific type hints for `method` @@ -53,99 +42,53 @@ class ReceivedMessage(NamedTuple): properties: spec.BasicProperties body: bytes - - class TwistedChannel: - - on_closed: Deferred[Union[twisted.python.failure.Failure, Exception, str]] - + on_closed: Deferred[twisted.python.failure.Failure | Exception | str] def __init__(self, channel: Channel) -> None: ... - @property def channel_number(self) -> int: ... @property def connection(self) -> Connection: ... - @property def is_closed(self) -> bool: ... @property def is_closing(self) -> bool: ... @property def is_open(self) -> bool: ... - @property def flow_active(self) -> bool: ... @property - def consumer_tags(self) -> List[str]: ... - - def callback_deferred( - self, - deferred: Deferred[Any], - replies: Sequence[Any], - ) -> None: ... - + def consumer_tags(self) -> list[str]: ... + def callback_deferred(self, deferred: Deferred[Any], replies: Sequence[Any]) -> None: ... # ReceivedMessage.method: spec.Basic.Return def add_on_return_callback(self, callback: Callable[[ReceivedMessage], None]) -> None: ... def basic_ack(self, delivery_tag: int = ..., multiple: bool = ...) -> None: ... def basic_cancel(self, consumer_tag: str = ...) -> None: ... - - # ReceivedMessage.method: spec.Basic.Deliver def basic_consume( self, queue: str, auto_ack: bool = ..., exclusive: bool = ..., - consumer_tag: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., - ) -> Deferred[Tuple[ClosableDeferredQueue[ReceivedMessage], str]]: ... - + consumer_tag: str | None = ..., + arguments: Mapping[str, Any] | None = ..., + ) -> Deferred[tuple[ClosableDeferredQueue[ReceivedMessage], str]]: ... # ReceivedMessage.method: spec.Basic.GetOk - def basic_get( - self, - queue: str, - auto_ack: bool = ..., - ) -> Deferred[ReceivedMessage]: ... - - def basic_nack( - self, - delivery_tag: Optional[int] = ..., - multiple: bool = ..., - requeue: bool = ..., - ) -> None: ... - + 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: bytes | str, - properties: Optional[spec.BasicProperties] = ..., - mandatory: bool = ..., + self, exchange: str, routing_key: str, body: AnyStr, properties: spec.BasicProperties | None = ..., mandatory: bool = ... ) -> Deferred[None]: ... - def basic_qos( - self, - prefetch_size: int = ..., - prefetch_count: int = ..., - global_qos: bool = ..., + self, prefetch_size: int = ..., prefetch_count: int = ..., global_qos: bool = ... ) -> Deferred[frame.Method[spec.Basic.QosOk]]: ... - def basic_reject(self, delivery_tag: int, requeue: bool = ...) -> None: ... - def basic_recover( - self, requeue: bool = ... - ) -> Deferred[frame.Method[spec.Basic.RecoverOk]]: ... - + def basic_recover(self, requeue: bool = ...) -> Deferred[frame.Method[spec.Basic.RecoverOk]]: ... def close(self, reply_code: int = ..., reply_text: str = ...) -> None: ... def confirm_delivery(self) -> Deferred[frame.Method[spec.Confirm.SelectOk]]: ... - def exchange_bind( - self, - destination: str, - source: str, - routing_key: str = ..., - arguments: Optional[Mapping[str, Any]] = ..., + self, destination: str, source: str, routing_key: str = ..., arguments: Mapping[str, Any] | None = ... ) -> Deferred[frame.Method[spec.Exchange.BindOk]]: ... - def exchange_declare( self, exchange: str, @@ -154,34 +97,23 @@ class TwistedChannel: durable: bool = ..., auto_delete: bool = ..., internal: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> Deferred[frame.Method[spec.Exchange.DeclareOk]]: ... - def exchange_delete( - self, - exchange: Optional[str] = ..., - if_unused: bool = ..., + self, exchange: str | None = ..., if_unused: bool = ... ) -> Deferred[frame.Method[spec.Exchange.DeleteOk]]: ... - def exchange_unbind( self, - destination: Optional[str] = ..., - source: Optional[str] = ..., + destination: str | None = ..., + source: str | None = ..., routing_key: str = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> Deferred[frame.Method[spec.Exchange.UnbindOk]]: ... - def flow(self, active: bool) -> Deferred[frame.Method[spec.Channel.FlowOk]]: ... def open(self) -> None: ... - def queue_bind( - self, - queue: str, - exchange: str, - routing_key: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., + self, queue: str, exchange: str, routing_key: str | None = ..., arguments: Mapping[str, Any] | None = ... ) -> Deferred[frame.Method[spec.Queue.BindOk]]: ... - def queue_declare( self, queue: str, @@ -189,59 +121,35 @@ class TwistedChannel: durable: bool = ..., exclusive: bool = ..., auto_delete: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> Deferred[frame.Method[spec.Queue.DeclareOk]]: ... - def queue_delete( - self, - queue: str, - if_unused: bool = ..., - if_empty: bool = ..., + self, queue: str, if_unused: bool = ..., if_empty: bool = ... ) -> Deferred[frame.Method[spec.Queue.DeleteOk]]: ... - def queue_purge(self, queue: str) -> Deferred[frame.Method[spec.Queue.PurgeOk]]: ... - def queue_unbind( - self, - queue: str, - exchange: Optional[str] = ..., - routing_key: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., + self, queue: str, exchange: str | None = ..., routing_key: str | None = ..., arguments: Mapping[str, Any] | None = ... ) -> Deferred[frame.Method[spec.Queue.UnbindOk]]: ... - def tx_commit(self) -> Deferred[frame.Method[spec.Tx.CommitOk]]: ... def tx_rollback(self) -> Deferred[frame.Method[spec.Tx.RollbackOk]]: ... def tx_select(self) -> Deferred[frame.Method[spec.Tx.SelectOk]]: ... - class TwistedProtocolConnection(twisted.internet.protocol.Protocol): ready: Deferred[TwistedProtocolConnection] = ... - closed: Optional[Deferred[Union[twisted.python.failure.Failure, Exception]]] = ... - + closed: Deferred[twisted.python.failure.Failure | Exception] | None = ... def __init__( - self, - parameters: Optional[Parameters] = ..., - custom_reactor: Optional[twisted.internet.base.ReactorBase] = ..., + self, parameters: Parameters | None = ..., custom_reactor: twisted.internet.base.ReactorBase | None = ... ) -> None: ... - - def channel(self, channel_number: Optional[int] = ...) -> Deferred[TwistedChannel]: ... - + def channel(self, channel_number: int | None = ...) -> Deferred[TwistedChannel]: ... + @property + def is_open(self) -> bool: ... @property def is_closed(self) -> bool: ... - - def close( - self, - reply_code: int = ..., - reply_text: str = ..., - ) -> Deferred[Exception]: ... - + def close(self, reply_code: int = ..., reply_text: str = ...) -> Deferred[Exception]: ... # IProtocol methods - def dataReceived(self, data: bytes) -> None: ... def connectionLost(self, reason: twisted.python.failure.Failure = ...) -> None: ... def makeConnection(self, transport: twisted.internet.interfaces.ITransport) -> None: ... - # Our own methods - def connectionReady(self) -> TwistedProtocolConnection: ... diff --git a/pika-stubs/adapters/utils/connection_workflow.pyi b/pika-stubs/adapters/utils/connection_workflow.pyi index 061e01f..297b8f8 100644 --- a/pika-stubs/adapters/utils/connection_workflow.pyi +++ b/pika-stubs/adapters/utils/connection_workflow.pyi @@ -1,109 +1,54 @@ -from typing import Any, Callable, Union +from typing import Any +from typing import Callable -from ... import compat, connection +from ... import compat +from ... import connection from . import nbio_interface - -class AMQPConnectorException(Exception): - ... - - -class AMQPConnectorStackTimeout(AMQPConnectorException): - ... - - -class AMQPConnectorAborted(AMQPConnectorException): - ... - - -class AMQPConnectorWrongState(AMQPConnectorException): - ... - +class AMQPConnectorException(Exception): ... +class AMQPConnectorStackTimeout(AMQPConnectorException): ... +class AMQPConnectorAborted(AMQPConnectorException): ... +class AMQPConnectorWrongState(AMQPConnectorException): ... class AMQPConnectorPhaseErrorBase(AMQPConnectorException): exception: Any = ... - def __init__(self, exception: Any, *args: Any) -> None: ... - -class AMQPConnectorSocketConnectError(AMQPConnectorPhaseErrorBase): - ... - - -class AMQPConnectorTransportSetupError(AMQPConnectorPhaseErrorBase): - ... - - -class AMQPConnectorAMQPHandshakeError(AMQPConnectorPhaseErrorBase): - ... - - -class AMQPConnectionWorkflowAborted(AMQPConnectorException): - ... - - -class AMQPConnectionWorkflowWrongState(AMQPConnectorException): - ... - +class AMQPConnectorSocketConnectError(AMQPConnectorPhaseErrorBase): ... +class AMQPConnectorTransportSetupError(AMQPConnectorPhaseErrorBase): ... +class AMQPConnectorAMQPHandshakeError(AMQPConnectorPhaseErrorBase): ... +class AMQPConnectionWorkflowAborted(AMQPConnectorException): ... +class AMQPConnectionWorkflowWrongState(AMQPConnectorException): ... class AMQPConnectionWorkflowFailed(AMQPConnectorException): exceptions: Any = ... - def __init__(self, exceptions: Any, *args: Any) -> None: ... - class AMQPConnector: - def __init__(self, conn_factory: Any, nbio: Any) -> None: ... def start(self, addr_record: Any, conn_params: Any, on_done: Any) -> None: ... def abort(self) -> None: ... - class AbstractAMQPConnectionWorkflow(compat.AbstractBase): - def start( self, connection_configs: connection.Parameters, connector_factory: Callable[[], AMQPConnector], native_loop: object, - on_done: Callable[ - [ - Union[ - connection.Connection, - AMQPConnectionWorkflowFailed, - AMQPConnectionWorkflowAborted, - ], - ], - None - ], + on_done: Callable[[connection.Connection | AMQPConnectionWorkflowFailed | AMQPConnectionWorkflowAborted], None], ) -> None: ... - def abort(self) -> None: ... - class AMQPConnectionWorkflow(AbstractAMQPConnectionWorkflow): - def __init__(self, _until_first_amqp_attempt: bool = ...) -> None: ... - def set_io_services(self, nbio: nbio_interface.AbstractIOServices) -> None: ... - def start( self, connection_configs: connection.Parameters, connector_factory: Callable[[], AMQPConnector], native_loop: object, - on_done: Callable[ - [ - Union[ - connection.Connection, - AMQPConnectionWorkflowFailed, - AMQPConnectionWorkflowAborted, - ], - ], - None - ], + on_done: Callable[[connection.Connection | AMQPConnectionWorkflowFailed | AMQPConnectionWorkflowAborted], None], ) -> None: ... - def abort(self) -> None: ... diff --git a/pika-stubs/adapters/utils/io_services_utils.pyi b/pika-stubs/adapters/utils/io_services_utils.pyi index bea5e4b..ade6232 100644 --- a/pika-stubs/adapters/utils/io_services_utils.pyi +++ b/pika-stubs/adapters/utils/io_services_utils.pyi @@ -2,39 +2,27 @@ from __future__ import annotations import ssl from socket import socket -from typing import Any, Callable, Optional, Tuple, Union +from typing import Any +from typing import Callable from . import nbio_interface +def check_callback_arg(callback: Callable[..., Any], name: str) -> None: ... +def check_fd_arg(fd: int) -> None: ... class SocketConnectionMixin: - def connect_socket( - self, - sock: socket, - resolved_addr: Any, - on_done: Callable[[Optional[BaseException]], None], + self, sock: socket, resolved_addr: Any, on_done: Callable[[BaseException | None], None] ) -> nbio_interface.AbstractIOReference: ... - class StreamingConnectionMixin: - def create_streaming_connection( self, protocol_factory: Callable[[], nbio_interface.AbstractStreamProtocol], sock: socket, on_done: Callable[ - [ - Union[ - BaseException, - Tuple[ - nbio_interface.AbstractStreamTransport, - nbio_interface.AbstractStreamProtocol, - ], - ] - ], - None, + [BaseException | tuple[nbio_interface.AbstractStreamTransport, nbio_interface.AbstractStreamProtocol]], None ], - ssl_context: ssl.SSLContext | None = None, - server_hostname: str | None = None, + ssl_context: ssl.SSLContext | None = ..., + server_hostname: str | None = ..., ) -> nbio_interface.AbstractIOReference: ... diff --git a/pika-stubs/adapters/utils/nbio_interface.pyi b/pika-stubs/adapters/utils/nbio_interface.pyi index bb93d5c..f393c4d 100644 --- a/pika-stubs/adapters/utils/nbio_interface.pyi +++ b/pika-stubs/adapters/utils/nbio_interface.pyi @@ -2,13 +2,18 @@ from __future__ import annotations import abc import ssl -from socket import AddressFamily, SocketKind, socket -from typing import Any, AnyStr, Callable, IO, List, Optional, Text, Tuple, Union +from socket import AddressFamily +from socket import SocketKind +from socket import socket +from typing import IO +from typing import Any +from typing import AnyStr +from typing import Callable +from typing import Text from ... import compat class AbstractIOServices(compat.AbstractBase): - @abc.abstractmethod def get_native_ioloop(self) -> object: ... @abc.abstractmethod @@ -21,56 +26,32 @@ class AbstractIOServices(compat.AbstractBase): def add_callback_threadsafe(self, callback: Callable[[], None]) -> None: ... @abc.abstractmethod def call_later(self, delay: float, callback: Callable[[], None]) -> AbstractTimerReference: ... - @abc.abstractmethod def getaddrinfo( self, - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], - on_done: Callable[ - [ - Union[ - BaseException, - List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]], - ] - ], - None, - ], + host: bytearray | bytes | Text | None, + port: str | int | None, + on_done: Callable[[BaseException | list[tuple[AddressFamily, SocketKind, int, str, tuple[Any, ...]]]], None], family: int = ..., socktype: int = ..., proto: int = ..., flags: int = ..., ) -> AbstractIOReference: ... - @abc.abstractmethod def connect_socket( - self, - sock: socket, - resolved_addr: Any, - on_done: Callable[[Optional[BaseException]], None], + self, sock: socket, resolved_addr: Any, on_done: Callable[[BaseException | None], None] ) -> AbstractIOReference: ... - @abc.abstractmethod def create_streaming_connection( self, protocol_factory: Callable[[], AbstractStreamProtocol], sock: socket, - on_done: Callable[ - [ - Union[ - BaseException, - Tuple[AbstractStreamTransport, AbstractStreamProtocol], - ] - ], - None, - ], - ssl_context: ssl.SSLContext | None = None, - server_hostname: str | None = None, + on_done: Callable[[BaseException | tuple[AbstractStreamTransport, AbstractStreamProtocol]], None], + ssl_context: ssl.SSLContext | None = ..., + server_hostname: str | None = ..., ) -> AbstractIOReference: ... - class AbstractFileDescriptorServices(compat.AbstractBase): - @abc.abstractmethod def set_reader(self, fd: IO[AnyStr], on_readable: Callable[[], None]) -> None: ... @abc.abstractmethod @@ -80,33 +61,25 @@ class AbstractFileDescriptorServices(compat.AbstractBase): @abc.abstractmethod def remove_writer(self, fd: IO[AnyStr]) -> bool: ... - class AbstractTimerReference(compat.AbstractBase): - @abc.abstractmethod def cancel(self) -> None: ... - class AbstractIOReference(compat.AbstractBase): - @abc.abstractmethod def cancel(self) -> bool: ... - class AbstractStreamProtocol(compat.AbstractBase): - @abc.abstractmethod def connection_made(self, transport: AbstractStreamTransport) -> None: ... @abc.abstractmethod - def connection_lost(self, error: Optional[BaseException]) -> None: ... + def connection_lost(self, error: BaseException | None) -> None: ... @abc.abstractmethod def eof_received(self) -> Any: ... @abc.abstractmethod def data_received(self, data: bytes) -> None: ... - class AbstractStreamTransport(compat.AbstractBase): - @abc.abstractmethod def abort(self) -> None: ... @abc.abstractmethod diff --git a/pika-stubs/adapters/utils/selector_ioloop_adapter.pyi b/pika-stubs/adapters/utils/selector_ioloop_adapter.pyi index e2bc0e6..71b325c 100644 --- a/pika-stubs/adapters/utils/selector_ioloop_adapter.pyi +++ b/pika-stubs/adapters/utils/selector_ioloop_adapter.pyi @@ -1,26 +1,22 @@ -import abc -from socket import AddressFamily, SocketKind -from typing import ( - Any, - AnyStr, - Callable, - Generic, - IO, - List, - Optional, - Text, - Tuple, - TypeVar, - Union, -) +from __future__ import annotations -from . import io_services_utils, nbio_interface +import abc +from socket import AddressFamily +from socket import SocketKind +from typing import IO +from typing import Any +from typing import AnyStr +from typing import Callable +from typing import Generic +from typing import Text +from typing import TypeVar -_Timeout = TypeVar('_Timeout', bound=object) +from . import io_services_utils +from . import nbio_interface +_Timeout = TypeVar("_Timeout", bound=object) class AbstractSelectorIOLoop(Generic[_Timeout], metaclass=abc.ABCMeta): - @property @abc.abstractmethod def READ(self) -> int: ... @@ -30,7 +26,6 @@ class AbstractSelectorIOLoop(Generic[_Timeout], metaclass=abc.ABCMeta): @property @abc.abstractmethod def ERROR(self) -> int: ... - @abc.abstractmethod def close(self) -> None: ... @abc.abstractmethod @@ -43,21 +38,13 @@ class AbstractSelectorIOLoop(Generic[_Timeout], metaclass=abc.ABCMeta): def remove_timeout(self, timeout_handle: _Timeout) -> None: ... @abc.abstractmethod def add_callback(self, callback: Callable[[], None]) -> None: ... - @abc.abstractmethod - def add_handler( - self, - fd: IO[AnyStr], - handler: Callable[[IO[AnyStr], int], None], - events: int, - ) -> None: ... - + def add_handler(self, fd: IO[AnyStr], handler: Callable[[IO[AnyStr], int], None], events: int) -> None: ... @abc.abstractmethod def update_handler(self, fd: IO[AnyStr], events: int) -> None: ... @abc.abstractmethod def remove_handler(self, fd: IO[AnyStr]) -> None: ... - class SelectorIOServicesAdapter( Generic[_Timeout], io_services_utils.SocketConnectionMixin, @@ -65,39 +52,23 @@ class SelectorIOServicesAdapter( nbio_interface.AbstractIOServices, nbio_interface.AbstractFileDescriptorServices, ): - def __init__(self, native_loop: AbstractSelectorIOLoop[_Timeout]) -> None: ... def get_native_ioloop(self) -> AbstractSelectorIOLoop[_Timeout]: ... def close(self) -> None: ... def run(self) -> None: ... def stop(self) -> None: ... def add_callback_threadsafe(self, callback: Callable[[], None]) -> None: ... - - def call_later( - self, - delay: float, - callback: Callable[[], None], - ) -> nbio_interface.AbstractTimerReference: ... - + def call_later(self, delay: float, callback: Callable[[], None]) -> nbio_interface.AbstractTimerReference: ... def getaddrinfo( self, - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], - on_done: Callable[ - [ - Union[ - BaseException, - List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]], - ] - ], - None, - ], + host: bytearray | bytes | Text | None, + port: str | int | None, + on_done: Callable[[BaseException | list[tuple[AddressFamily, SocketKind, int, str, tuple[Any, ...]]]], None], family: int = ..., socktype: int = ..., proto: int = ..., flags: int = ..., ) -> nbio_interface.AbstractIOReference: ... - def set_reader(self, fd: IO[AnyStr], on_readable: Callable[[], None]) -> None: ... def remove_reader(self, fd: IO[AnyStr]) -> bool: ... def set_writer(self, fd: IO[AnyStr], on_writable: Callable[[], None]) -> None: ... diff --git a/pika-stubs/amqp_object.pyi b/pika-stubs/amqp_object.pyi index e95944c..1a221c1 100644 --- a/pika-stubs/amqp_object.pyi +++ b/pika-stubs/amqp_object.pyi @@ -1,30 +1,22 @@ from __future__ import annotations -from typing import Optional - - class AMQPObject: NAME: str = ... - INDEX: Optional[int] = ... - + INDEX: int | None = ... class Class(AMQPObject): NAME: str = ... - class Method(AMQPObject): NAME: str = ... - @property def synchronous(self) -> bool: ... - def get_properties(self) -> Properties: ... def get_body(self) -> bytes: ... - class Properties(AMQPObject): NAME: str = ... diff --git a/pika-stubs/callback.pyi b/pika-stubs/callback.pyi index 5a0df78..562bf18 100644 --- a/pika-stubs/callback.pyi +++ b/pika-stubs/callback.pyi @@ -1,18 +1,20 @@ -from typing import Any, Callable, Mapping, Optional, Tuple, Union +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any +from typing import Callable from . import amqp_object -_Prefix = Union[int, str] +_Prefix = int | str _Key = Any _Caller = object _Callback = Callable[..., Any] - def name_or_value(value: amqp_object.AMQPObject) -> str: ... def sanitize_prefix(function: _Callback) -> _Callback: ... def check_for_prefix_and_key(function: _Callback) -> _Callback: ... - class CallbackManager: CALLS: str = ... @@ -21,36 +23,20 @@ class CallbackManager: CALLBACK: str = ... ONE_SHOT: str = ... ONLY_CALLER: str = ... - def add( self, prefix: _Prefix, key: _Key, callback: _Callback, one_shot: bool = ..., - only_caller: Optional[_Caller] = ..., - arguments: Optional[Mapping[str, Any]] = ..., - ) -> Tuple[_Prefix, Any]: ... - + only_caller: _Caller | None = ..., + arguments: Mapping[str, Any] | None = ..., + ) -> tuple[_Prefix, Any]: ... def clear(self) -> None: ... def cleanup(self, prefix: _Prefix) -> bool: ... - - def pending(self, prefix: _Prefix, key: _Key) -> Optional[int]: ... - - def process( - self, - prefix: _Prefix, - key: _Key, - caller: _Caller, - *args: Any, - **keywords: Any, - ) -> bool: ... - + def pending(self, prefix: _Prefix, key: _Key) -> int | None: ... + def process(self, prefix: _Prefix, key: _Key, caller: _Caller, *args: Any, **keywords: Any) -> bool: ... def remove( - self, - prefix: _Prefix, - key: _Key, - callback_value: Optional[_Callback] = ..., - arguments: Optional[Mapping[str, Any]] = ..., + self, prefix: _Prefix, key: _Key, callback_value: _Callback | None = ..., arguments: Mapping[str, Any] | None = ... ) -> bool: ... def remove_all(self, prefix: _Prefix, key: _Key) -> None: ... diff --git a/pika-stubs/channel.pyi b/pika-stubs/channel.pyi index 4627ca6..2216d42 100644 --- a/pika-stubs/channel.pyi +++ b/pika-stubs/channel.pyi @@ -1,47 +1,48 @@ from __future__ import annotations -from typing import Any, Callable, List, Mapping, Optional, Sequence, Tuple, Union - +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 -from . import ( - callback, - connection as connection_, - frame, - spec, -) +from . import amqp_object +from . import callback +from . import connection as connection_ +from . import frame +from . import spec from .exchange_type import ExchangeType MAX_CHANNELS: Literal[65535] # per AMQP 0.9.1 spec. -_OnAckNackCallback = Callable[[frame.Method[Union[spec.Basic.Ack, spec.Basic.Nack]]], None] +_OnAckNackCallback = Callable[[frame.Method[spec.Basic.Ack | spec.Basic.Nack]], None] _OnConfirmDeliveryCallback = Callable[[frame.Method[spec.Confirm.SelectOk]], None] _OnBasicConsumeCallback = Callable[[frame.Method[spec.Basic.ConsumeOk]], None] -_OnBasicGetCallback = Callable[['Channel', spec.Basic.GetOk, spec.BasicProperties, bytes], None] +_OnBasicGetCallback = Callable[[Channel, spec.Basic.GetOk, spec.BasicProperties, bytes], None] _OnBasicRecoverCallback = Callable[[frame.Method[spec.Basic.RecoverOk]], None] _OnBasicQosCallback = Callable[[frame.Method[spec.Basic.QosOk]], None] _OnBasicCancelCallback = Callable[[frame.Method[spec.Basic.CancelOk]], None] -_OnCloseCallback = Callable[['Channel', Exception], None] +_OnCloseCallback = Callable[[Channel, Exception], None] _OnExchangeBindCallback = Callable[[frame.Method[spec.Exchange.BindOk]], None] _OnExchangeDeclareCallback = Callable[[frame.Method[spec.Exchange.DeclareOk]], None] _OnExchangeDeleteCallback = Callable[[frame.Method[spec.Exchange.DeleteOk]], None] _OnExchangeUnbindCallback = Callable[[frame.Method[spec.Exchange.UnbindOk]], None] _OnFlowCallback = Callable[[bool], None] -_OnMessageCallback = Callable[['Channel', spec.Basic.Deliver, spec.BasicProperties, bytes], None] -_OnOpenCallback = Callable[['Channel'], None] +_OnMessageCallback = Callable[[Channel, spec.Basic.Deliver, spec.BasicProperties, bytes], None] +_OnOpenCallback = Callable[[Channel], None] _OnQueueBindCallback = Callable[[frame.Method[spec.Queue.BindOk]], None] _OnQueueDeclareCallback = Callable[[frame.Method[spec.Queue.DeclareOk]], None] _OnQueueDeleteCallback = Callable[[frame.Method[spec.Queue.DeleteOk]], None] _OnQueuePurgeCallback = Callable[[frame.Method[spec.Queue.PurgeOk]], None] _OnQueueUnbindCallback = Callable[[frame.Method[spec.Queue.UnbindOk]], None] -_OnReturnCallback = Callable[['Channel', spec.Basic.Return, spec.BasicProperties, bytes], None] +_OnReturnCallback = Callable[[Channel, spec.Basic.Return, spec.BasicProperties, bytes], None] _OnTxCommitCallback = Callable[[spec.Tx.CommitOk], None] _OnTxRollbackCallback = Callable[[spec.Tx.RollbackOk], None] _OnTxSelectCallback = Callable[[spec.Tx.SelectOk], None] - class Channel: - CLOSED: int = ... OPENING: int = ... OPEN: int = ... @@ -51,110 +52,53 @@ class Channel: callbacks: callback.CallbackManager = ... connection: connection_.Connection = ... flow_active: bool = ... - - def __init__( - self, - connection: connection_.Connection, - channel_number: int, - on_open_callback: _OnOpenCallback, - ) -> None: ... - + def __init__(self, connection: connection_.Connection, channel_number: int, on_open_callback: _OnOpenCallback) -> None: ... def __int__(self) -> int: ... - - def add_callback( - self, - callback: Callable[..., Any], - replies: Sequence[Any], - one_shot: bool = ..., - ) -> None: ... - + def add_callback(self, callback: Callable[..., Any], replies: Sequence[Any], one_shot: bool = ...) -> None: ... def add_on_cancel_callback(self, callback: _OnBasicCancelCallback) -> None: ... def add_on_close_callback(self, callback: _OnCloseCallback) -> None: ... def add_on_flow_callback(self, callback: _OnFlowCallback) -> None: ... def add_on_return_callback(self, callback: _OnReturnCallback) -> None: ... - - def basic_ack( - self, - delivery_tag: int = ..., - multiple: bool = ..., - ) -> None: ... - - def basic_cancel( - self, - consumer_tag: str = ..., - callback: Optional[_OnBasicCancelCallback] = ..., - ) -> None: ... - + def basic_ack(self, delivery_tag: int = ..., multiple: bool = ...) -> None: ... + def basic_cancel(self, consumer_tag: str = ..., callback: _OnBasicCancelCallback | None = ...) -> None: ... def basic_consume( self, queue: str, on_message_callback: _OnMessageCallback, auto_ack: bool = ..., exclusive: bool = ..., - consumer_tag: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., - callback: Optional[_OnBasicConsumeCallback] = ..., + consumer_tag: str | None = ..., + arguments: Mapping[str, Any] | None = ..., + callback: _OnBasicConsumeCallback | None = ..., ) -> str: ... - - def basic_get( - self, - queue: str, - callback: _OnBasicGetCallback, - auto_ack: bool = ..., - ) -> None: ... - - def basic_nack( - self, - delivery_tag: Optional[int] = ..., - multiple: bool = ..., - requeue: bool = ..., - ) -> None: ... - + def basic_get(self, queue: str, callback: _OnBasicGetCallback, auto_ack: bool = ...) -> None: ... + def basic_nack(self, delivery_tag: int | None = ..., multiple: bool = ..., requeue: bool = ...) -> None: ... def basic_publish( - self, - exchange: str, - routing_key: str, - body: bytes | str, - properties: Optional[spec.BasicProperties] = ..., - mandatory: bool = ..., + self, exchange: str, routing_key: str, body: AnyStr, properties: spec.BasicProperties | None = ..., mandatory: bool = ... ) -> None: ... - def basic_qos( self, prefetch_size: int = ..., prefetch_count: int = ..., global_qos: bool = ..., - callback: Optional[_OnBasicQosCallback] = ..., + callback: _OnBasicQosCallback | None = ..., ) -> None: ... - def basic_reject(self, delivery_tag: int = ..., requeue: bool = ...) -> None: ... - - def basic_recover( - self, - requeue: bool = ..., - callback: Optional[_OnBasicRecoverCallback] = ..., - ) -> None: ... - + def basic_recover(self, requeue: bool = ..., callback: _OnBasicRecoverCallback | None = ...) -> None: ... def close(self, reply_code: int = ..., reply_text: str = ...) -> None: ... - def confirm_delivery( - self, - ack_nack_callback: _OnAckNackCallback, - callback: Optional[_OnConfirmDeliveryCallback] = ..., + self, ack_nack_callback: _OnAckNackCallback, callback: _OnConfirmDeliveryCallback | None = ... ) -> None: ... - @property - def consumer_tags(self) -> List[str]: ... - + def consumer_tags(self) -> list[str]: ... def exchange_bind( self, destination: str, source: str, routing_key: str = ..., - arguments: Optional[Mapping[str, Any]] = ..., - callback: Optional[_OnExchangeBindCallback] = ..., + arguments: Mapping[str, Any] | None = ..., + callback: _OnExchangeBindCallback | None = ..., ) -> None: ... - def exchange_declare( self, exchange: str, @@ -163,46 +107,36 @@ class Channel: durable: bool = ..., auto_delete: bool = ..., internal: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., - callback: Optional[_OnExchangeDeclareCallback] = ..., + arguments: Mapping[str, Any] | None = ..., + callback: _OnExchangeDeclareCallback | None = ..., ) -> None: ... - def exchange_delete( - self, - exchange: Optional[str] = ..., - if_unused: bool = ..., - callback: Optional[_OnExchangeDeleteCallback] = ..., + self, exchange: str | None = ..., if_unused: bool = ..., callback: _OnExchangeDeleteCallback | None = ... ) -> None: ... - def exchange_unbind( self, - destination: Optional[str] = ..., - source: Optional[str] = ..., + destination: str | None = ..., + source: str | None = ..., routing_key: str = ..., - arguments: Optional[Mapping[str, Any]] = ..., - callback: Optional[_OnExchangeUnbindCallback] = ..., + arguments: Mapping[str, Any] | None = ..., + callback: _OnExchangeUnbindCallback | None = ..., ) -> None: ... - - def flow(self, active: bool, callback: Optional[_OnFlowCallback] = ...) -> None: ... - + def flow(self, active: bool, callback: _OnFlowCallback | None = ...) -> None: ... @property def is_closed(self) -> bool: ... @property def is_closing(self) -> bool: ... @property def is_open(self) -> bool: ... - def open(self) -> None: ... - def queue_bind( self, queue: str, exchange: str, - routing_key: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., - callback: Optional[_OnQueueBindCallback] = ..., + routing_key: str | None = ..., + arguments: Mapping[str, Any] | None = ..., + callback: _OnQueueBindCallback | None = ..., ) -> None: ... - def queue_declare( self, queue: str, @@ -210,33 +144,34 @@ class Channel: durable: bool = ..., exclusive: bool = ..., auto_delete: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., - callback: Optional[_OnQueueDeclareCallback] = ..., + arguments: Mapping[str, Any] | None = ..., + callback: _OnQueueDeclareCallback | None = ..., ) -> None: ... - def queue_delete( - self, - queue: str, - if_unused: bool = ..., - if_empty: bool = ..., - callback: Optional[_OnQueueDeleteCallback] = ..., + self, queue: str, if_unused: bool = ..., if_empty: bool = ..., callback: _OnQueueDeleteCallback | None = ... ) -> None: ... - - def queue_purge( - self, - queue: str, - callback: Optional[_OnQueuePurgeCallback] = ..., - ) -> None: ... - + def queue_purge(self, queue: str, callback: _OnQueuePurgeCallback | None = ...) -> None: ... def queue_unbind( self, queue: str, - exchange: Optional[str] = ..., - routing_key: Optional[str] = ..., - arguments: Optional[Mapping[str, Any]] = ..., - callback: Optional[_OnQueueUnbindCallback] = ..., - ) -> None: ... - - def tx_commit(self, callback: Optional[_OnTxCommitCallback] = ...) -> None: ... - def tx_rollback(self, callback: Optional[_OnTxRollbackCallback] = ...) -> None: ... - def tx_select(self, callback: Optional[_OnTxSelectCallback] = ...) -> None: ... + exchange: str | None = ..., + routing_key: str | None = ..., + arguments: Mapping[str, Any] | None = ..., + callback: _OnQueueUnbindCallback | None = ..., + ) -> None: ... + def tx_commit(self, callback: _OnTxCommitCallback | None = ...) -> None: ... + def tx_rollback(self, callback: _OnTxRollbackCallback | None = ...) -> None: ... + def tx_select(self, callback: _OnTxSelectCallback | None = ...) -> None: ... + +_Method = TypeVar("_Method", bound=amqp_object.Method) + +class ContentFrameAssembler: + def __init__(self) -> None: ... + def process( + self, frame_value: frame.Method[_Method] | frame.Header | frame.Body + ) -> tuple[frame.Method[_Method], frame.Header, bytes] | None: ... + def _finish(self) -> tuple[frame.Method[_Method], frame.Header, bytes]: ... + def _handle_body_frame( + self, body_frame: frame.Method[_Method] | frame.Header | frame.Body + ) -> tuple[frame.Method[_Method], frame.Header, bytes] | None: ... + def _reset(self) -> None: ... diff --git a/pika-stubs/compat.pyi b/pika-stubs/compat.pyi index b77ba59..0e60a68 100644 --- a/pika-stubs/compat.pyi +++ b/pika-stubs/compat.pyi @@ -1,5 +1,56 @@ +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 +from typing import TypeVar +from typing import ValuesView + +PY2: bool +PY3: bool +RE_NUM: re.Pattern[str] + +ON_LINUX: bool +ON_OSX: bool +ON_WINDOWS: bool + +class AbstractBase(metaclass=abc.ABCMeta): ... + +SOCKET_ERROR: Type[Exception] +SOL_TCP: int + +basestring: tuple[Type[str]] +str_or_bytes: tuple[Type[str], Type[bytes]] +xrange: Type[range] +unicode_type: Type[str] + +def time_now() -> float: ... + +_T1 = TypeVar("_T1") +_T2 = TypeVar("_T2") + +def dictkeys(dct: dict[_T1, _T2]) -> list[KeysView[_T1]]: ... +def dictvalues(dct: dict[_T1, _T2]) -> list[ValuesView[_T2]]: ... +def dict_iteritems(dct: dict[_T1, _T2]) -> ItemsView[_T1, _T2]: ... +def dict_itervalues(dct: dict[_T1, _T2]) -> ValuesView[_T2]: ... +def byte(*args: int) -> bytes: ... + +class long(int): + def __str__(self) -> str: ... + def __repr__(self) -> str: ... +def canonical_str(value: Any) -> str: ... +def is_integer(value: Any) -> bool: ... +def as_bytes(value: AnyStr) -> bytes: ... +def to_digit(value: str) -> int: ... +def get_linux_version(release_str: str) -> tuple[int, int, int]: ... -class AbstractBase(metaclass=abc.ABCMeta): - pass +HAVE_SIGNAL: bool +EINTR_IS_EXPOSED: bool +LINUX_VERSION: tuple[int, int, int] | None +_LOCALHOST: str +_LOCALHOST_V6: str diff --git a/pika-stubs/connection.pyi b/pika-stubs/connection.pyi index 9d97dbf..82f2d09 100644 --- a/pika-stubs/connection.pyi +++ b/pika-stubs/connection.pyi @@ -1,100 +1,80 @@ from __future__ import annotations -import numbers import ssl -from typing import Any, Callable, Dict, Mapping, Optional, Union - +from collections.abc import Mapping +from typing import Any +from typing import Callable +from typing import Type from typing_extensions import Literal -from . import ( - callback, - channel as channel_, - compat, - credentials as credentials_, - frame, - spec, -) +from . import callback +from . import channel as channel_ +from . import compat +from . import credentials as credentials_ +from . import frame +from . import spec PRODUCT: str -_OnHeartbeatTimeoutCallback = Callable[['Connection', numbers.Integral], int] -_OnCloseCallback = Callable[['Connection', Exception], None] -_OnConnectionBlockedCallback = Callable[ - [ - 'Connection', - frame.Method[spec.Connection.Blocked] - ], - None, -] -_OnConnectionUnblockedCallback = Callable[ - [ - 'Connection', - frame.Method[spec.Connection.Unblocked], - ], - None, -] -_OnOpenCallback = Callable[['Connection'], None] -_OnOpenErrorCallback = Callable[['Connection', Union[str, Exception]], None] +_OnHeartbeatTimeoutCallback = Callable[[Connection, int], int] +_OnCloseCallback = Callable[[Connection, Exception], None] +_OnConnectionBlockedCallback = Callable[[Connection, frame.Method[spec.Connection.Blocked]], None] +_OnConnectionUnblockedCallback = Callable[[Connection, frame.Method[spec.Connection.Unblocked]], None] +_OnOpenCallback = Callable[[Connection], None] +_OnOpenErrorCallback = Callable[[Connection, str | Exception], None] _OnOpenChannelCallback = Callable[[channel_.Channel], None] - class Parameters: DEFAULT_USERNAME: str = ... DEFAULT_PASSWORD: str = ... - DEFAULT_BLOCKED_CONNECTION_TIMEOUT: Optional[numbers.Real] = ... + DEFAULT_BLOCKED_CONNECTION_TIMEOUT: float | int | None = ... DEFAULT_CHANNEL_MAX: int = ... - DEFAULT_CLIENT_PROPERTIES: Optional[Mapping[str, Any]] = ... - DEFAULT_CREDENTIALS: credentials_.VALID_TYPES = ... + DEFAULT_CLIENT_PROPERTIES: Mapping[str, Any] | None = ... + DEFAULT_CREDENTIALS: credentials_._VALID_TYPES = ... DEFAULT_CONNECTION_ATTEMPTS: Literal[1] = ... DEFAULT_FRAME_MAX: int = ... - DEFAULT_HEARTBEAT_TIMEOUT: Optional[Union[numbers.Integral, _OnHeartbeatTimeoutCallback]] = ... + DEFAULT_HEARTBEAT_TIMEOUT: int | _OnHeartbeatTimeoutCallback | None = ... DEFAULT_HOST: str = ... DEFAULT_LOCALE: str = ... DEFAULT_PORT: int = ... - DEFAULT_RETRY_DELAY: numbers.Real = ... - DEFAULT_SOCKET_TIMEOUT: numbers.Real = ... - DEFAULT_STACK_TIMEOUT: numbers.Real = ... + DEFAULT_RETRY_DELAY: float | int = ... + DEFAULT_SOCKET_TIMEOUT: float | int = ... + DEFAULT_STACK_TIMEOUT: float | int = ... DEFAULT_SSL: bool = ... - DEFAULT_SSL_OPTIONS: Optional[SSLOptions] = ... + DEFAULT_SSL_OPTIONS: SSLOptions | None = ... DEFAULT_SSL_PORT: int = ... DEFAULT_VIRTUAL_HOST: str = ... - DEFAULT_TCP_OPTIONS: Optional[Mapping[str, Any]] = ... - + DEFAULT_TCP_OPTIONS: Mapping[str, Any] | None = ... @property - def blocked_connection_timeout(self) -> numbers.Real: ... + def blocked_connection_timeout(self) -> float | int: ... @blocked_connection_timeout.setter - def blocked_connection_timeout(self, value: Optional[numbers.Real]) -> None: ... + def blocked_connection_timeout(self, value: float | int | None) -> None: ... @property - def channel_max(self) -> numbers.Integral: ... + def channel_max(self) -> int: ... @channel_max.setter - def channel_max(self, value: numbers.Integral) -> None: ... + def channel_max(self, value: int) -> None: ... @property - def client_properties(self) -> Optional[Mapping[str, Any]]: ... + def client_properties(self) -> Mapping[str, Any] | None: ... @client_properties.setter - def client_properties(self, value: Optional[Mapping[str, Any]]) -> None: ... + def client_properties(self, value: Mapping[str, Any] | None) -> None: ... @property - def connection_attempts(self) -> numbers.Integral: ... + def connection_attempts(self) -> int: ... @connection_attempts.setter - def connection_attempts(self, value: numbers.Integral) -> None: ... + def connection_attempts(self, value: int) -> None: ... @property - def credentials(self) -> credentials_.VALID_TYPES: ... + def credentials(self) -> credentials_._VALID_TYPES: ... @credentials.setter - def credentials(self, value: credentials_.VALID_TYPES) -> None: ... + def credentials(self, value: credentials_._VALID_TYPES) -> None: ... @property - def frame_max(self) -> numbers.Integral: ... + def frame_max(self) -> int: ... @frame_max.setter - def frame_max(self, value: numbers.Integral) -> None: ... + def frame_max(self, value: int) -> None: ... @property - def heartbeat(self) -> Optional[Union[numbers.Integral, _OnHeartbeatTimeoutCallback]]: ... - + def heartbeat(self) -> int | _OnHeartbeatTimeoutCallback | None: ... @heartbeat.setter - def heartbeat( - self, - value: Optional[Union[numbers.Integral, _OnHeartbeatTimeoutCallback]], - ) -> None: ... - + def heartbeat(self, value: int | _OnHeartbeatTimeoutCallback | None) -> None: ... @property def host(self) -> str: ... @host.setter @@ -108,70 +88,61 @@ class Parameters: @port.setter def port(self, value: int) -> None: ... @property - def retry_delay(self) -> numbers.Real: ... + def retry_delay(self) -> float | int: ... @retry_delay.setter - def retry_delay(self, value: numbers.Real) -> None: ... + def retry_delay(self, value: float | int) -> None: ... @property - def socket_timeout(self) -> Optional[numbers.Real]: ... + def socket_timeout(self) -> float | int | None: ... @socket_timeout.setter - def socket_timeout(self, value: Optional[numbers.Real]) -> None: ... + def socket_timeout(self, value: float | int | None) -> None: ... @property - def stack_timeout(self) -> Optional[numbers.Real]: ... + def stack_timeout(self) -> float | int | None: ... @stack_timeout.setter - def stack_timeout(self, value: Optional[numbers.Real]) -> None: ... + def stack_timeout(self, value: float | int | None) -> None: ... @property - def ssl_options(self) -> Optional[SSLOptions]: ... + def ssl_options(self) -> SSLOptions | None: ... @ssl_options.setter - def ssl_options(self, value: Optional[SSLOptions]) -> None: ... + def ssl_options(self, value: SSLOptions | None) -> None: ... @property def virtual_host(self) -> str: ... @virtual_host.setter def virtual_host(self, value: str) -> None: ... @property - def tcp_options(self) -> Optional[Mapping[str, Any]]: ... + def tcp_options(self) -> Mapping[str, Any] | None: ... @tcp_options.setter - def tcp_options(self, value: Optional[Mapping[str, Any]]) -> None: ... - + def tcp_options(self, value: Mapping[str, Any] | None) -> None: ... class ConnectionParameters(Parameters): - - class _DEFAULT: - ... - + class _DEFAULT: ... def __init__( self, - host: Union[str, _DEFAULT] = ..., - port: Union[int, _DEFAULT] = ..., - virtual_host: Union[str, _DEFAULT] = ..., - credentials: Union[credentials_.VALID_TYPES, _DEFAULT] = ..., - channel_max: Union[int, _DEFAULT] = ..., - frame_max: Union[int, _DEFAULT] = ..., - heartbeat: Union[int, _OnHeartbeatTimeoutCallback, None, _DEFAULT] = ..., - ssl_options: Union[SSLOptions, _DEFAULT] = ..., - connection_attempts: Union[int, _DEFAULT] = ..., - retry_delay: Union[numbers.Real, _DEFAULT] = ..., - socket_timeout: Union[numbers.Real, _DEFAULT] = ..., - stack_timeout: Union[numbers.Real, _DEFAULT] = ..., - locale: Union[str, _DEFAULT] = ..., - blocked_connection_timeout: Union[numbers.Real, None, _DEFAULT] = ..., - client_properties: Union[Mapping[str, Any], None, _DEFAULT] = ..., - tcp_options: Union[Mapping[str, Any], None, _DEFAULT] = ..., + host: str | Type[_DEFAULT] = ..., + port: int | Type[_DEFAULT] = ..., + virtual_host: str | Type[_DEFAULT] = ..., + credentials: credentials_._VALID_TYPES | Type[_DEFAULT] = ..., + channel_max: int | Type[_DEFAULT] = ..., + frame_max: int | Type[_DEFAULT] = ..., + heartbeat: int | None | _OnHeartbeatTimeoutCallback | Type[_DEFAULT] = ..., + ssl_options: SSLOptions | Type[_DEFAULT] = ..., + connection_attempts: int | Type[_DEFAULT] = ..., + retry_delay: float | int | Type[_DEFAULT] = ..., + socket_timeout: float | int | Type[_DEFAULT] = ..., + stack_timeout: float | int | Type[_DEFAULT] = ..., + locale: str | Type[_DEFAULT] = ..., + blocked_connection_timeout: float | int | None | Type[_DEFAULT] = ..., + client_properties: Mapping[str, Any] | None | Type[_DEFAULT] = ..., + tcp_options: Mapping[str, Any] | None | Type[_DEFAULT] = ..., **kwargs: Any, ): ... - class URLParameters(Parameters): - def __init__(self, url: str) -> None: ... - class SSLOptions: context: ssl.SSLContext = ... - server_hostname: Optional[str] = ... - - def __init__(self, context: ssl.SSLContext, server_hostname: Optional[str] = ...): ... - + server_hostname: str | None = ... + def __init__(self, context: ssl.SSLContext, server_hostname: str | None = ...): ... class Connection(compat.AbstractBase): @@ -187,55 +158,34 @@ class Connection(compat.AbstractBase): CONNECTION_OPEN: int = ... CONNECTION_CLOSING: int = ... - connection_state: Optional[str] = ... - params: Optional[Parameters] = ... + connection_state: str | None = ... + params: Parameters | None = ... callbacks: callback.CallbackManager = ... - server_capabilities: Optional[Mapping[str, Any]] = ... - server_properties: Optional[Dict[str, Any]] = ... - known_hosts: Optional[str] = ... + server_capabilities: Mapping[str, Any] | None = ... + server_properties: dict[str, Any] | None = ... + known_hosts: str | None = ... bytes_sent: int = ... bytes_received: int = ... frames_sent: int = ... frames_received: int = ... - def __init__( self, - parameters: Optional[Parameters] = ..., - on_open_callback: Optional[_OnOpenCallback] = ..., - on_open_error_callback: Optional[_OnOpenErrorCallback] = ..., - on_close_callback: Optional[_OnCloseCallback] = ..., + parameters: Parameters | None = ..., + on_open_callback: _OnOpenCallback | None = ..., + on_open_error_callback: _OnOpenErrorCallback | None = ..., + on_close_callback: _OnCloseCallback | None = ..., internal_connection_workflow: bool = ..., ) -> None: ... - def add_on_close_callback(self, callback: _OnCloseCallback) -> None: ... - - def add_on_connection_blocked_callback( - self, - callback: _OnConnectionBlockedCallback, - ) -> None: ... - - def add_on_connection_unblocked_callback( - self, - callback: _OnConnectionUnblockedCallback, - ) -> None: ... - + def add_on_connection_blocked_callback(self, callback: _OnConnectionBlockedCallback) -> None: ... + def add_on_connection_unblocked_callback(self, callback: _OnConnectionUnblockedCallback) -> None: ... def add_on_open_callback(self, callback: _OnOpenCallback) -> None: ... - - def add_on_open_error_callback( - self, - callback: _OnOpenErrorCallback, - remove_default: bool = ..., - ) -> None: ... - + def add_on_open_error_callback(self, callback: _OnOpenErrorCallback, remove_default: bool = ...) -> None: ... def channel( - self, - channel_number: Optional[int] = ..., - on_open_callback: Optional[_OnOpenChannelCallback] = ..., + self, channel_number: int | None = ..., on_open_callback: _OnOpenChannelCallback | None = ... ) -> channel_.Channel: ... - def close(self, reply_code: int = ..., reply_text: str = ...) -> None: ... - @property def is_closed(self) -> bool: ... @property diff --git a/pika-stubs/credentials.pyi b/pika-stubs/credentials.pyi index 29206f9..b728df3 100644 --- a/pika-stubs/credentials.pyi +++ b/pika-stubs/credentials.pyi @@ -1,7 +1,8 @@ -from typing import Optional, Tuple, Union +from __future__ import annotations -from . import spec +from typing import Type +from . import spec class PlainCredentials: @@ -10,29 +11,17 @@ class PlainCredentials: username: str = ... password: str = ... erase_on_connect: bool = ... - def __init__(self, username: str, password: str, erase_on_connect: bool = ...) -> None: ... - - def response_for( - self, - start: spec.Connection.Start, - ) -> Tuple[Optional[str], Optional[str]]: ... - + def response_for(self, start: spec.Connection.Start) -> tuple[str | None, str | None]: ... def erase_credentials(self) -> None: ... - class ExternalCredentials: TYPE: str = ... erase_on_connect: bool = ... - - def response_for( - self, - start: spec.Connection.Start, - ) -> Tuple[Optional[str], Optional[str]]: ... - + def response_for(self, start: spec.Connection.Start) -> tuple[str | None, str | None]: ... def erase_credentials(self) -> None: ... - -VALID_TYPES = Union[PlainCredentials, ExternalCredentials] +_VALID_TYPES = PlainCredentials | ExternalCredentials +VALID_TYPES: list[_VALID_TYPES] diff --git a/pika-stubs/exceptions.pyi b/pika-stubs/exceptions.pyi index d0a6bd4..dbaa3ae 100644 --- a/pika-stubs/exceptions.pyi +++ b/pika-stubs/exceptions.pyi @@ -1,177 +1,66 @@ -from typing import Sequence +from __future__ import annotations -from .adapters import blocking_connection - - -class AMQPError(Exception): - ... - - -class AMQPConnectionError(AMQPError): - ... - - -class ConnectionOpenAborted(AMQPConnectionError): - ... - - -class StreamLostError(AMQPConnectionError): - ... - - -class IncompatibleProtocolError(AMQPConnectionError): - ... - - -class AuthenticationError(AMQPConnectionError): - ... - - -class ProbableAuthenticationError(AMQPConnectionError): - ... - - -class ProbableAccessDeniedError(AMQPConnectionError): - ... - - -class NoFreeChannels(AMQPConnectionError): - ... +from collections.abc import Sequence +from .adapters import blocking_connection -class ConnectionWrongStateError(AMQPConnectionError): - ... - +class AMQPError(Exception): ... +class AMQPConnectionError(AMQPError): ... +class ConnectionOpenAborted(AMQPConnectionError): ... +class StreamLostError(AMQPConnectionError): ... +class IncompatibleProtocolError(AMQPConnectionError): ... +class AuthenticationError(AMQPConnectionError): ... +class ProbableAuthenticationError(AMQPConnectionError): ... +class ProbableAccessDeniedError(AMQPConnectionError): ... +class NoFreeChannels(AMQPConnectionError): ... +class ConnectionWrongStateError(AMQPConnectionError): ... class ConnectionClosed(AMQPConnectionError): - def __init__(self, reply_code: int, reply_text: str) -> None: ... - @property def reply_code(self) -> int: ... - @property def reply_text(self) -> str: ... - -class ConnectionClosedByBroker(ConnectionClosed): - ... - - -class ConnectionClosedByClient(ConnectionClosed): - ... - - -class ConnectionBlockedTimeout(AMQPConnectionError): - ... - - -class AMQPHeartbeatTimeout(AMQPConnectionError): - ... - - -class AMQPChannelError(AMQPError): - ... - - -class ChannelWrongStateError(AMQPChannelError): - ... - +class ConnectionClosedByBroker(ConnectionClosed): ... +class ConnectionClosedByClient(ConnectionClosed): ... +class ConnectionBlockedTimeout(AMQPConnectionError): ... +class AMQPHeartbeatTimeout(AMQPConnectionError): ... +class AMQPChannelError(AMQPError): ... +class ChannelWrongStateError(AMQPChannelError): ... class ChannelClosed(AMQPChannelError): - def __init__(self, reply_code: int, reply_text: str) -> None: ... - @property def reply_code(self) -> int: ... - @property def reply_text(self) -> str: ... - -class ChannelClosedByBroker(ChannelClosed): - ... - - -class ChannelClosedByClient(ChannelClosed): - ... - - -class DuplicateConsumerTag(AMQPChannelError): - ... - - -class ConsumerCancelled(AMQPChannelError): - ... - +class ChannelClosedByBroker(ChannelClosed): ... +class ChannelClosedByClient(ChannelClosed): ... +class DuplicateConsumerTag(AMQPChannelError): ... +class ConsumerCancelled(AMQPChannelError): ... class UnroutableError(AMQPChannelError): messages: Sequence[blocking_connection.ReturnedMessage] = ... - - def __init__( - self, - messages: Sequence[blocking_connection.ReturnedMessage], - ) -> None: ... - + def __init__(self, messages: Sequence[blocking_connection.ReturnedMessage]) -> None: ... class NackError(AMQPChannelError): messages: Sequence[blocking_connection.ReturnedMessage] = ... - - def __init__( - self, - messages: Sequence[blocking_connection.ReturnedMessage], - ) -> None: ... - - -class InvalidChannelNumber(AMQPError): - ... - - -class ProtocolSyntaxError(AMQPError): - ... - - -class UnexpectedFrameError(ProtocolSyntaxError): - ... - - -class ProtocolVersionMismatch(ProtocolSyntaxError): - ... - - -class BodyTooLongError(ProtocolSyntaxError): - ... - - -class InvalidFrameError(ProtocolSyntaxError): - ... - - -class InvalidFieldTypeException(ProtocolSyntaxError): - ... - - -class UnsupportedAMQPFieldException(ProtocolSyntaxError): - ... - - -class MethodNotImplemented(AMQPError): - ... - - -class ChannelError(Exception): - ... - - -class ReentrancyError(Exception): - ... - - -class ShortStringTooLong(AMQPError): - ... - - -class DuplicateGetOkCallback(ChannelError): - ... + def __init__(self, messages: Sequence[blocking_connection.ReturnedMessage]) -> None: ... + +class InvalidChannelNumber(AMQPError): ... +class ProtocolSyntaxError(AMQPError): ... +class UnexpectedFrameError(ProtocolSyntaxError): ... +class ProtocolVersionMismatch(ProtocolSyntaxError): ... +class BodyTooLongError(ProtocolSyntaxError): ... +class InvalidFrameError(ProtocolSyntaxError): ... +class InvalidFieldTypeException(ProtocolSyntaxError): ... +class UnsupportedAMQPFieldException(ProtocolSyntaxError): ... +class MethodNotImplemented(AMQPError): ... +class ChannelError(Exception): ... +class ReentrancyError(Exception): ... +class ShortStringTooLong(AMQPError): ... +class DuplicateGetOkCallback(ChannelError): ... diff --git a/pika-stubs/exchange_type.pyi b/pika-stubs/exchange_type.pyi index 9ce96dc..73cbf36 100644 --- a/pika-stubs/exchange_type.pyi +++ b/pika-stubs/exchange_type.pyi @@ -1,6 +1,5 @@ from enum import Enum - class ExchangeType(Enum): direct: str fanout: str diff --git a/pika-stubs/frame.pyi b/pika-stubs/frame.pyi index fecc731..90dbdf8 100644 --- a/pika-stubs/frame.pyi +++ b/pika-stubs/frame.pyi @@ -1,9 +1,13 @@ -from typing import Any, Generic, Optional, Tuple, TypeVar +from __future__ import annotations -from . import amqp_object, spec +from typing import Any +from typing import Generic +from typing import TypeVar -_Method = TypeVar('_Method', bound=amqp_object.Method) +from . import amqp_object +from . import spec +_Method = TypeVar("_Method", bound=amqp_object.Method) class Frame(amqp_object.AMQPObject): @@ -11,55 +15,40 @@ class Frame(amqp_object.AMQPObject): frame_type: int = ... channel_number: int = ... - def __init__(self, frame_type: int, channel_number: int) -> None: ... def marshal(self) -> bytes: ... - class Method(Frame, Generic[_Method]): NAME: str = ... method: _Method = ... - def __init__(self, channel_number: int, method: _Method) -> None: ... def marshal(self) -> bytes: ... - class Header(Frame): NAME: str = ... body_size: Any = ... properties: spec.BasicProperties = ... - - def __init__( - self, - channel_number: int, - body_size: int, - props: spec.BasicProperties, - ) -> None: ... + def __init__(self, channel_number: int, body_size: int, props: spec.BasicProperties) -> None: ... def marshal(self) -> bytes: ... - class Body(Frame): NAME: str = ... fragment: bytes = ... - def __init__(self, channel_number: int, fragment: bytes) -> None: ... def marshal(self) -> bytes: ... - class Heartbeat(Frame): NAME: str = ... - def __init__(self) -> None: ... def marshal(self) -> bytes: ... - class ProtocolHeader(amqp_object.AMQPObject): NAME: str = ... @@ -69,14 +58,7 @@ class ProtocolHeader(amqp_object.AMQPObject): major: int = ... minor: int = ... revision: int = ... - - def __init__( - self, - major: Optional[int] = ..., - minor: Optional[int] = ..., - revision: Optional[int] = ..., - ) -> None: ... + def __init__(self, major: int | None = ..., minor: int | None = ..., revision: int | None = ...) -> None: ... def marshal(self) -> bytes: ... - -def decode_frame(data_in: bytes) -> Tuple[int, Optional[Frame]]: ... +def decode_frame(data_in: bytes) -> tuple[int, Frame | None]: ... diff --git a/pika-stubs/spec.pyi b/pika-stubs/spec.pyi index 7a7bff7..85d730b 100644 --- a/pika-stubs/spec.pyi +++ b/pika-stubs/spec.pyi @@ -1,10 +1,12 @@ from __future__ import annotations -from typing import Any, List, Mapping, Optional, Type - +from collections.abc import Mapping +from typing import Any +from typing import Type from typing_extensions import Literal -from . import amqp_object +from . import amqp_object as amqp_object +from .compat import str_or_bytes as str_or_bytes from .exchange_type import ExchangeType PROTOCOL_VERSION: Any @@ -41,340 +43,249 @@ SYNTAX_ERROR: Literal[502] TRANSIENT_DELIVERY_MODE: Literal[1] UNEXPECTED_FRAME: Literal[505] - class Connection(amqp_object.Class): INDEX: Literal[0x000A] - NAME: Literal['Connection'] - + NAME: Literal["Connection"] class Start(amqp_object.Method): INDEX: Literal[0x000A000A] - NAME: Literal['Connection.Start'] + NAME: Literal["Connection.Start"] version_major: int = ... version_minor: int = ... - server_properties: Optional[Mapping[str, Any]] = ... + server_properties: Mapping[str, Any] | None = ... mechanisms: str = ... locales: str = ... - def __init__( self, version_major: int = ..., version_minor: int = ..., - server_properties: Optional[Mapping[str, Any]] = ..., + server_properties: Mapping[str, Any] | None = ..., mechanisms: str = ..., locales: str = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.Start: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class StartOk(amqp_object.Method): INDEX: Literal[0x000A000B] - NAME: Literal['Connection.StartOk'] + NAME: Literal["Connection.StartOk"] - client_properties: Optional[Mapping[str, Any]] = ... + client_properties: Mapping[str, Any] | None = ... mechanism: str = ... - response: Optional[str] = ... + response: str | None = ... locale: str = ... - def __init__( self, - client_properties: Optional[Mapping[str, Any]] = ..., + client_properties: Mapping[str, Any] | None = ..., mechanism: str = ..., - response: Optional[str] = ..., + response: str | None = ..., locale: str = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.StartOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Secure(amqp_object.Method): INDEX: Literal[0x000A0014] - NAME: Literal['Connection.Secure'] - - challenge: Optional[str] = ... - - def __init__(self, challenge: Optional[str] = None) -> None: ... + NAME: Literal["Connection.Secure"] + challenge: str | None = ... + def __init__(self, challenge: str | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.Secure: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class SecureOk(amqp_object.Method): INDEX: Literal[0x000A0015] - NAME: Literal['Connection.SecureOk'] - - response: Optional[str] = ... - - def __init__(self, response: Optional[str] = None) -> None: ... + NAME: Literal["Connection.SecureOk"] + response: str | None = ... + def __init__(self, response: str | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.SecureOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Tune(amqp_object.Method): INDEX: Literal[0x000A001E] - NAME: Literal['Connection.Tune'] + NAME: Literal["Connection.Tune"] channel_max: int = ... frame_max: int = ... heartbeat: int = ... - def __init__(self, channel_max: int = ..., frame_max: int = ..., heartbeat: int = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.Tune: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class TuneOk(amqp_object.Method): INDEX: Literal[0x000A001F] - NAME: Literal['Connection.TuneOk'] + NAME: Literal["Connection.TuneOk"] channel_max: int = ... frame_max: int = ... heartbeat: int = ... - - def __init__( - self, - channel_max: int = ..., - frame_max: int = ..., - heartbeat: int = ..., - ) -> None: ... - + def __init__(self, channel_max: int = ..., frame_max: int = ..., heartbeat: int = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.TuneOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Open(amqp_object.Method): INDEX: Literal[0x000A0028] - NAME: Literal['Connection.Open'] + NAME: Literal["Connection.Open"] virtual_host: str = ... capabilities: str = ... insist: bool = ... - - def __init__( - self, - virtual_host: str = ..., - capabilities: str = ..., - insist: bool = ..., - ) -> None: ... - + def __init__(self, virtual_host: str = ..., capabilities: str = ..., insist: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.Open: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class OpenOk(amqp_object.Method): INDEX: Literal[0x000A0029] - NAME: Literal['Connection.OpenOk'] + NAME: Literal["Connection.OpenOk"] known_hosts: str = ... - def __init__(self, known_hosts: str = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.OpenOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Close(amqp_object.Method): INDEX: Literal[0x000A0032] - NAME: Literal['Connection.Close'] + NAME: Literal["Connection.Close"] - reply_code: Optional[int] = ... + reply_code: int | None = ... reply_text: str = ... - class_id: Optional[int] = ... - method_id: Optional[int] = ... - + class_id: int | None = ... + method_id: int | None = ... def __init__( - self, - reply_code: Optional[int] = ..., - reply_text: str = ..., - class_id: Optional[int] = ..., - method_id: Optional[int] = ..., + self, reply_code: int | None = ..., reply_text: str = ..., class_id: int | None = ..., method_id: int | None = ... ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.Close: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class CloseOk(amqp_object.Method): INDEX: Literal[0x000A0033] - NAME: Literal['Connection.CloseOk'] - + NAME: Literal["Connection.CloseOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.CloseOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Blocked(amqp_object.Method): INDEX: Literal[0x000A003C] - NAME: Literal['Connection.Blocked'] + NAME: Literal["Connection.Blocked"] reason: str = ... - def __init__(self, reason: str = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.Blocked: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Unblocked(amqp_object.Method): INDEX: Literal[0x000A003D] - NAME: Literal['Connection.Unblocked'] - + NAME: Literal["Connection.Unblocked"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Connection.Unblocked: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Channel(amqp_object.Class): INDEX: Literal[0x0014] - NAME: Literal['Channel'] - + NAME: Literal["Channel"] class Open(amqp_object.Method): INDEX: Literal[0x0014000A] - NAME: Literal['Channel.Open'] + NAME: Literal["Channel.Open"] out_of_band: str = ... - def __init__(self, out_of_band: str = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Channel.Open: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class OpenOk(amqp_object.Method): INDEX: Literal[0x0014000B] - NAME: Literal['Channel.OpenOk'] + NAME: Literal["Channel.OpenOk"] channel_id: str = ... - def __init__(self, channel_id: str = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Channel.OpenOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Flow(amqp_object.Method): INDEX: Literal[0x00140014] - NAME: Literal['Channel.Flow'] - - active: Optional[bool] = ... - - def __init__(self, active: Optional[bool] = ...) -> None: ... + NAME: Literal["Channel.Flow"] + active: bool | None = ... + def __init__(self, active: bool | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Channel.Flow: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class FlowOk(amqp_object.Method): INDEX: Literal[0x00140015] - NAME: Literal['Channel.FlowOk'] - - active: Optional[bool] = ... - - def __init__(self, active: Optional[bool] = ...) -> None: ... + NAME: Literal["Channel.FlowOk"] + active: bool | None = ... + def __init__(self, active: bool | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Channel.FlowOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Close(amqp_object.Method): INDEX: Literal[0x00140028] - NAME: Literal['Channel.Close'] + NAME: Literal["Channel.Close"] - reply_code: Optional[int] = ... + reply_code: int | None = ... reply_text: str = ... - class_id: Optional[int] = ... - method_id: Optional[int] = ... - + class_id: int | None = ... + method_id: int | None = ... def __init__( - self, - reply_code: Optional[int] = ..., - reply_text: str = ..., - class_id: Optional[int] = ..., - method_id: Optional[int] = ..., + self, reply_code: int | None = ..., reply_text: str = ..., class_id: int | None = ..., method_id: int | None = ... ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Channel.Close: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class CloseOk(amqp_object.Method): INDEX: Literal[0x00140029] - NAME: Literal['Channel.CloseOk'] - + NAME: Literal["Channel.CloseOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Channel.CloseOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Access(amqp_object.Class): INDEX: Literal[0x001E] - NAME: Literal['Access'] - + NAME: Literal["Access"] class Request(amqp_object.Method): INDEX: Literal[0x001E000A] - NAME: Literal['Access.Request'] + NAME: Literal["Access.Request"] realm: str = ... exclusive: bool = ... @@ -382,7 +293,6 @@ class Access(amqp_object.Class): active: bool = ... write: bool = ... read: bool = ... - def __init__( self, realm: str = ..., @@ -392,202 +302,159 @@ class Access(amqp_object.Class): write: bool = ..., read: bool = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Access.Request: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class RequestOk(amqp_object.Method): INDEX: Literal[0x001E000B] - NAME: Literal['Access.RequestOk'] + NAME: Literal["Access.RequestOk"] ticket: int = ... - def __init__(self, ticket: int = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Access.RequestOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Exchange(amqp_object.Class): INDEX: Literal[0x0028] - NAME: Literal['Exchange'] - + NAME: Literal["Exchange"] class Declare(amqp_object.Method): INDEX: Literal[0x0028000A] - NAME: Literal['Exchange.Declare'] + NAME: Literal["Exchange.Declare"] ticket: int = ... - exchange: Optional[str] = ... + exchange: str | None = ... type: str = ... passive: bool = ... durable: bool = ... auto_delete: bool = ... internal: bool = ... nowait: bool = ... - arguments: Optional[Mapping[str, Any]] = ... - + arguments: Mapping[str, Any] | None = ... def __init__( self, ticket: int = ..., - exchange: Optional[str] = ..., + exchange: str | None = ..., type: ExchangeType = ..., passive: bool = ..., durable: bool = ..., auto_delete: bool = ..., internal: bool = ..., nowait: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.Declare: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class DeclareOk(amqp_object.Method): INDEX: Literal[0x0028000B] - NAME: Literal['Exchange.DeclareOk'] - + NAME: Literal["Exchange.DeclareOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.DeclareOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Delete(amqp_object.Method): INDEX: Literal[0x00280014] - NAME: Literal['Exchange.Delete'] + NAME: Literal["Exchange.Delete"] ticket: int = ... - exchange: Optional[str] = ... + exchange: str | None = ... if_unused: bool = ... nowait: bool = ... - - def __init__( - self, - ticket: int = ..., - exchange: Optional[str] = ..., - if_unused: bool = ..., - nowait: bool = ..., - ) -> None: ... - + def __init__(self, ticket: int = ..., exchange: str | None = ..., if_unused: bool = ..., nowait: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.Delete: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class DeleteOk(amqp_object.Method): INDEX: Literal[0x00280015] - NAME: Literal['Exchange.DeleteOk'] - + NAME: Literal["Exchange.DeleteOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.DeleteOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Bind(amqp_object.Method): INDEX: Literal[0x0028001E] - NAME: Literal['Exchange.Bind'] + NAME: Literal["Exchange.Bind"] ticket: int = ... - destination: Optional[str] = ... - source: Optional[str] = ... + destination: str | None = ... + source: str | None = ... routing_key: str = ... nowait: bool = ... - arguments: Optional[Mapping[str, Any]] = ... - + arguments: Mapping[str, Any] | None = ... def __init__( self, ticket: int = ..., - destination: Optional[str] = ..., - source: Optional[str] = ..., + destination: str | None = ..., + source: str | None = ..., routing_key: str = ..., nowait: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.Bind: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class BindOk(amqp_object.Method): INDEX: Literal[0x0028001F] - NAME: Literal['Exchange.BindOk'] - + NAME: Literal["Exchange.BindOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.BindOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Unbind(amqp_object.Method): INDEX: Literal[0x00280028] - NAME: Literal['Exchange.Unbind'] + NAME: Literal["Exchange.Unbind"] ticket: int = ... - destination: Optional[str] = ... - source: Optional[str] = ... + destination: str | None = ... + source: str | None = ... routing_key: str = ... nowait: bool = ... - arguments: Optional[Mapping[str, Any]] = ... - + arguments: Mapping[str, Any] | None = ... def __init__( self, ticket: int = ..., - destination: Optional[str] = ..., - source: Optional[str] = ..., + destination: str | None = ..., + source: str | None = ..., routing_key: str = ..., nowait: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.Unbind: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class UnbindOk(amqp_object.Method): INDEX: Literal[0x00280033] - NAME: Literal['Exchange.UnbindOk'] - + NAME: Literal["Exchange.UnbindOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Exchange.UnbindOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Queue(amqp_object.Class): INDEX: Literal[0x0032] - NAME: Literal['Queue'] - + NAME: Literal["Queue"] class Declare(amqp_object.Method): INDEX: Literal[0x0032000A] - NAME: Literal['Queue.Declare'] + NAME: Literal["Queue.Declare"] ticket: int = ... queue: str = ... @@ -596,8 +463,7 @@ class Queue(amqp_object.Class): exclusive: bool = ... auto_delete: bool = ... nowait: bool = ... - arguments: Optional[Mapping[str, Any]] = ... - + arguments: Mapping[str, Any] | None = ... def __init__( self, ticket: int = ..., @@ -607,234 +473,171 @@ class Queue(amqp_object.Class): exclusive: bool = ..., auto_delete: bool = ..., nowait: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.Declare: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class DeclareOk(amqp_object.Method): INDEX: Literal[0x0032000B] - NAME: Literal['Queue.DeclareOk'] - - queue: Optional[str] = ... - message_count: Optional[int] = ... - consumer_count: Optional[int] = ... + NAME: Literal["Queue.DeclareOk"] + queue: str | None = ... + message_count: int | None = ... + consumer_count: int | None = ... def __init__( - self, - queue: Optional[str] = ..., - message_count: Optional[int] = ..., - consumer_count: Optional[int] = ..., + self, queue: str | None = ..., message_count: int | None = ..., consumer_count: int | None = ... ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.DeclareOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Bind(amqp_object.Method): INDEX: Literal[0x00320014] - NAME: Literal['Queue.Bind'] + NAME: Literal["Queue.Bind"] ticket: int = ... queue: str = ... - exchange: Optional[str] = ... + exchange: str | None = ... routing_key: str = ... nowait: bool = ... - arguments: Optional[Mapping[str, Any]] = ... - + arguments: Mapping[str, Any] | None = ... def __init__( self, ticket: int = ..., queue: str = ..., - exchange: Optional[str] = ..., + exchange: str | None = ..., routing_key: str = ..., nowait: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.Bind: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class BindOk(amqp_object.Method): INDEX: Literal[0x00320015] - NAME: Literal['Queue.BindOk'] - + NAME: Literal["Queue.BindOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.BindOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Purge(amqp_object.Method): INDEX: Literal[0x0032001E] - NAME: Literal['Queue.Purge'] + NAME: Literal["Queue.Purge"] ticket: int = ... queue: str = ... nowait: bool = ... - - def __init__( - self, - ticket: int = ..., - queue: str = ..., - nowait: bool = ..., - ) -> None: ... - + def __init__(self, ticket: int = ..., queue: str = ..., nowait: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.Purge: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class PurgeOk(amqp_object.Method): INDEX: Literal[0x0032001F] - NAME: Literal['Queue.PurgeOk'] - - message_count: Optional[int] = ... - - def __init__(self, message_count: Optional[int] = ...) -> None: ... + NAME: Literal["Queue.PurgeOk"] + message_count: int | None = ... + def __init__(self, message_count: int | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.PurgeOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Delete(amqp_object.Method): INDEX: Literal[0x00320028] - NAME: Literal['Queue.Delete'] + NAME: Literal["Queue.Delete"] ticket: int = ... queue: str = ... if_unused: bool = ... if_empty: bool = ... nowait: bool = ... - def __init__( - self, - ticket: int = ..., - queue: str = ..., - if_unused: bool = ..., - if_empty: bool = ..., - nowait: bool = ..., + self, ticket: int = ..., queue: str = ..., if_unused: bool = ..., if_empty: bool = ..., nowait: bool = ... ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.Delete: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class DeleteOk(amqp_object.Method): INDEX: Literal[0x00320029] - NAME: Literal['Queue.DeleteOk'] - - message_count: Optional[int] = ... - - def __init__(self, message_count: Optional[int] = ...) -> None: ... + NAME: Literal["Queue.DeleteOk"] + message_count: int | None = ... + def __init__(self, message_count: int | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.DeleteOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Unbind(amqp_object.Method): INDEX: Literal[0x00320032] - NAME: Literal['Queue.Unbind'] + NAME: Literal["Queue.Unbind"] ticket: int = ... queue: str = ... - exchange: Optional[str] = ... + exchange: str | None = ... routing_key: str = ... - arguments: Optional[Mapping[str, Any]] = ... - + arguments: Mapping[str, Any] | None = ... def __init__( self, ticket: int = ..., queue: str = ..., - exchange: Optional[str] = ..., + exchange: str | None = ..., routing_key: str = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.Unbind: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class UnbindOk(amqp_object.Method): INDEX: Literal[0x00320033] - NAME: Literal['Queue.UnbindOk'] - + NAME: Literal["Queue.UnbindOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Queue.UnbindOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Basic(amqp_object.Class): INDEX: Literal[0x003C] - NAME: Literal['Basic'] - + NAME: Literal["Basic"] class Qos(amqp_object.Method): INDEX: Literal[0x003C000A] - NAME: Literal['Basic.Qos'] + NAME: Literal["Basic.Qos"] prefetch_size: int = ... prefetch_count: int = ... global_qos: bool = ... - - def __init__( - self, - prefetch_size: int = ..., - prefetch_count: int = ..., - global_qos: bool = ..., - ) -> None: ... - + def __init__(self, prefetch_size: int = ..., prefetch_count: int = ..., global_qos: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Qos: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class QosOk(amqp_object.Method): INDEX: Literal[0x003C000B] - NAME: Literal['Basic.QosOk'] - + NAME: Literal["Basic.QosOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.QosOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Consume(amqp_object.Method): INDEX: Literal[0x003C0014] - NAME: Literal['Basic.Consume'] + NAME: Literal["Basic.Consume"] ticket: int = ... queue: str = ... @@ -843,8 +646,7 @@ class Basic(amqp_object.Class): no_ack: bool = ... exclusive: bool = ... nowait: bool = ... - arguments: Optional[Mapping[str, Any]] = ... - + arguments: Mapping[str, Any] | None = ... def __init__( self, ticket: int = ..., @@ -854,406 +656,298 @@ class Basic(amqp_object.Class): no_ack: bool = ..., exclusive: bool = ..., nowait: bool = ..., - arguments: Optional[Mapping[str, Any]] = ..., + arguments: Mapping[str, Any] | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Consume: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class ConsumeOk(amqp_object.Method): INDEX: Literal[0x003C0015] - NAME: Literal['Basic.ConsumeOk'] - - consumer_tag: Optional[int] = ... - - def __init__(self, consumer_tag: Optional[int] = ...) -> None: ... + NAME: Literal["Basic.ConsumeOk"] + consumer_tag: int | None = ... + def __init__(self, consumer_tag: int | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.ConsumeOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Cancel(amqp_object.Method): INDEX: Literal[0x003C001E] - NAME: Literal['Basic.Cancel'] + NAME: Literal["Basic.Cancel"] - consumer_tag: Optional[int] = ... + consumer_tag: int | None = ... nowait: bool = ... - - def __init__(self, consumer_tag: Optional[int] = ..., nowait: bool = ...) -> None: ... - + def __init__(self, consumer_tag: int | None = ..., nowait: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Cancel: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class CancelOk(amqp_object.Method): INDEX: Literal[0x003C001F] - NAME: Literal['Basic.CancelOk'] - - consumer_tag: Optional[int] = ... - - def __init__(self, consumer_tag: Optional[int] = ...) -> None: ... + NAME: Literal["Basic.CancelOk"] + consumer_tag: int | None = ... + def __init__(self, consumer_tag: int | None = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.CancelOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Publish(amqp_object.Method): INDEX: Literal[0x003C0028] - NAME: Literal['Basic.Publish'] + NAME: Literal["Basic.Publish"] ticket: int = ... exchange: str = ... routing_key: str = ... mandatory: bool = ... immediate: bool = ... - def __init__( - self, - ticket: int = ..., - exchange: str = ..., - routing_key: str = ..., - mandatory: bool = ..., - immediate: bool = ..., + self, ticket: int = ..., exchange: str = ..., routing_key: str = ..., mandatory: bool = ..., immediate: bool = ... ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Publish: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Return(amqp_object.Method): INDEX: Literal[0x003C0032] - NAME: Literal['Basic.Return'] + NAME: Literal["Basic.Return"] - reply_code: Optional[int] = ... + reply_code: int | None = ... reply_text: str = ... - exchange: Optional[str] = ... - routing_key: Optional[str] = ... - + exchange: str | None = ... + routing_key: str | None = ... def __init__( - self, - reply_code: Optional[int] = ..., - reply_text: str = ..., - exchange: Optional[str] = ..., - routing_key: Optional[str] = ..., + self, reply_code: int | None = ..., reply_text: str = ..., exchange: str | None = ..., routing_key: str | None = ... ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Return: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Deliver(amqp_object.Method): INDEX: Literal[0x003C003C] - NAME: Literal['Basic.Deliver'] + NAME: Literal["Basic.Deliver"] - consumer_tag: Optional[str] = ... - delivery_tag: Optional[int] = ... + consumer_tag: str | None = ... + delivery_tag: int | None = ... redelivered: bool = ... - exchange: Optional[str] = ... - routing_key: Optional[str] = ... - + exchange: str | None = ... + routing_key: str | None = ... def __init__( self, - consumer_tag: Optional[str] = ..., - delivery_tag: Optional[int] = ..., + consumer_tag: str | None = ..., + delivery_tag: int | None = ..., redelivered: bool = ..., - exchange: Optional[str] = ..., - routing_key: Optional[str] = ..., + exchange: str | None = ..., + routing_key: str | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Deliver: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Get(amqp_object.Method): INDEX: Literal[0x003C0046] - NAME: Literal['Basic.Get'] + NAME: Literal["Basic.Get"] ticket: int = ... queue: str = ... no_ack: bool = ... - - def __init__( - self, - ticket: int = ..., - queue: str = ..., - no_ack: bool = ..., - ) -> None: ... - + def __init__(self, ticket: int = ..., queue: str = ..., no_ack: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Get: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class GetOk(amqp_object.Method): INDEX: Literal[0x003C0047] - NAME: Literal['Basic.GetOk'] + NAME: Literal["Basic.GetOk"] - delivery_tag: Optional[int] = ... + delivery_tag: int | None = ... redelivered: bool = ... - exchange: Optional[str] = ... - routing_key: Optional[str] = ... - message_count: Optional[int] = ... - + exchange: str | None = ... + routing_key: str | None = ... + message_count: int | None = ... def __init__( self, - delivery_tag: Optional[int] = ..., + delivery_tag: int | None = ..., redelivered: bool = ..., - exchange: Optional[str] = ..., - routing_key: Optional[str] = ..., - message_count: Optional[int] = ..., + exchange: str | None = ..., + routing_key: str | None = ..., + message_count: int | None = ..., ) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.GetOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class GetEmpty(amqp_object.Method): INDEX: Literal[0x003C0048] - NAME: Literal['Basic.GetEmpty'] + NAME: Literal["Basic.GetEmpty"] cluster_id: str = ... - def __init__(self, cluster_id: str = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.GetEmpty: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Ack(amqp_object.Method): INDEX: Literal[0x003C0050] - NAME: Literal['Basic.Ack'] + NAME: Literal["Basic.Ack"] delivery_tag: int = ... multiple: bool = ... - def __init__(self, delivery_tag: int = ..., multiple: bool = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Ack: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Reject(amqp_object.Method): INDEX: Literal[0x003C005A] - NAME: Literal['Basic.Reject'] + NAME: Literal["Basic.Reject"] - delivery_tag: Optional[int] = ... + delivery_tag: int | None = ... requeue: bool = ... - - def __init__(self, delivery_tag: Optional[int] = ..., requeue: bool = ...) -> None: ... - + def __init__(self, delivery_tag: int | None = ..., requeue: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Reject: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class RecoverAsync(amqp_object.Method): INDEX: Literal[0x003C0064] - NAME: Literal['Basic.RecoverAsync'] + NAME: Literal["Basic.RecoverAsync"] requeue: bool = ... - def __init__(self, requeue: bool = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.RecoverAsync: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Recover(amqp_object.Method): INDEX: Literal[0x003C006E] - NAME: Literal['Basic.Recover'] + NAME: Literal["Basic.Recover"] requeue: bool = ... - def __init__(self, requeue: bool = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Recover: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class RecoverOk(amqp_object.Method): INDEX: Literal[0x003C006F] - NAME: Literal['Basic.RecoverOk'] - + NAME: Literal["Basic.RecoverOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.RecoverOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Nack(amqp_object.Method): INDEX: Literal[0x003C0078] - NAME: Literal['Basic.Nack'] + NAME: Literal["Basic.Nack"] delivery_tag: int = ... multiple: bool = ... requeue: bool = ... - - def __init__( - self, - delivery_tag: int = ..., - multiple: bool = ..., - requeue: bool = ..., - ) -> None: ... - + def __init__(self, delivery_tag: int = ..., multiple: bool = ..., requeue: bool = ...) -> None: ... @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Basic.Nack: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Tx(amqp_object.Class): INDEX: Literal[0x005A] - NAME: Literal['Tx'] - + NAME: Literal["Tx"] class Select(amqp_object.Method): INDEX: Literal[0x005A000A] - NAME: Literal['Tx.Select'] - + NAME: Literal["Tx.Select"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Tx.Select: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class SelectOk(amqp_object.Method): INDEX: Literal[0x005A000B] - NAME: Literal['Tx.SelectOk'] - + NAME: Literal["Tx.SelectOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Tx.SelectOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Commit(amqp_object.Method): INDEX: Literal[0x005A0014] - NAME: Literal['Tx.Commit'] - + NAME: Literal["Tx.Commit"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Tx.Commit: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class CommitOk(amqp_object.Method): INDEX: Literal[0x005A0015] - NAME: Literal['Tx.CommitOk'] - + NAME: Literal["Tx.CommitOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Tx.CommitOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Rollback(amqp_object.Method): INDEX: Literal[0x005A001E] - NAME: Literal['Tx.Rollback'] - + NAME: Literal["Tx.Rollback"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Tx.Rollback: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class RollbackOk(amqp_object.Method): INDEX: Literal[0x005A001F] - NAME: Literal['Tx.RollbackOk'] - + NAME: Literal["Tx.RollbackOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Tx.RollbackOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class Confirm(amqp_object.Class): INDEX: Literal[0x0055] - NAME: Literal['Confirm'] - + NAME: Literal["Confirm"] class Select(amqp_object.Method): INDEX: Literal[0x0055000A] - NAME: Literal['Confirm.Select'] + NAME: Literal["Confirm.Select"] nowait: bool = ... - def __init__(self, nowait: bool = ...) -> None: ... - @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Confirm.Select: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class SelectOk(amqp_object.Method): INDEX: Literal[0x0055000B] - NAME: Literal['Confirm.SelectOk'] - + NAME: Literal["Confirm.SelectOk"] @property def synchronous(self) -> bool: ... - def decode(self, encoded: bytes, offset: int = ...) -> Confirm.SelectOk: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... class BasicProperties(amqp_object.Properties): CLASS: Type[Basic] = ... INDEX: Literal[0x003C] - NAME: Literal['BasicProperties'] + NAME: Literal["BasicProperties"] FLAG_CONTENT_TYPE: int = ... FLAG_CONTENT_ENCODING: int = ... @@ -1270,45 +964,41 @@ class BasicProperties(amqp_object.Properties): FLAG_APP_ID: int = ... FLAG_CLUSTER_ID: int = ... - content_type: Optional[str] = ... - content_encoding: Optional[str] = ... - headers: Optional[Mapping[str, Any]] = ... - delivery_mode: Optional[int] = ... - priority: Optional[int] = ... - correlation_id: Optional[str] = ... - reply_to: Optional[str] = ... - expiration: Optional[str] = ... - message_id: Optional[str] = ... - timestamp: Optional[int] = ... - type: Optional[str] = ... - user_id: Optional[str] = ... - app_id: Optional[str] = ... - cluster_id: Optional[str] = ... - + content_type: str | None = ... + content_encoding: str | None = ... + headers: Mapping[str, Any] | None = ... + delivery_mode: int | 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: Optional[str] = ..., - content_encoding: Optional[str] = ..., - headers: Optional[Mapping[str, Any]] = ..., - delivery_mode: Optional[int] = ..., - priority: Optional[int] = ..., - correlation_id: Optional[str] = ..., - reply_to: Optional[str] = ..., - expiration: Optional[str] = ..., - message_id: Optional[str] = ..., - timestamp: Optional[int] = ..., - type: Optional[str] = ..., - user_id: Optional[str] = ..., - app_id: Optional[str] = ..., - cluster_id: Optional[str] = ..., + content_type: str | None = ..., + content_encoding: str | None = ..., + headers: Mapping[str, Any] | None = ..., + delivery_mode: int | 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 = ..., ) -> None: ... - def decode(self, encoded: bytes, offset: int = ...) -> BasicProperties: ... - def encode(self) -> List[bytes]: ... - + def encode(self) -> list[bytes]: ... methods: Mapping[int, amqp_object.Method] props: Mapping[int, amqp_object.Properties] - def has_content(methodNumber: int) -> bool: ... diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e7350d7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,32 @@ +[tool.black] +line-length = 130 +target-version = ['py37'] +include = '\.pyi?$' +exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.mypy_cache + | \.tox + | \.venv + | _build + | build + | dist + )/ +) +''' +skip_magic_trailing_comma = true + +[tool.isort] +profile = "black" +src_paths = [ + "pika-stubs", +] +combine_as_imports = true +line_length = 130 +force_single_line = true +use_parentheses = true +extra_standard_library = [ + "typing_extensions", +] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..e0bd218 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,58 @@ +# +# This file is autogenerated by pip-compile with python 3.10 +# To update, run: +# +# pip-compile --extra=dev --output-file=requirements-dev.txt setup.cfg +# +attrs==21.4.0 + # via + # automat + # flake8-pyi + # twisted +automat==20.2.0 + # via twisted +constantly==15.1.0 + # via twisted +flake8==4.0.1 + # via + # flake8-pyi + # pika-stubs (setup.cfg) +flake8-pyi==20.10.0 + # via pika-stubs (setup.cfg) +hyperlink==21.0.0 + # via twisted +idna==3.3 + # via hyperlink +incremental==21.3.0 + # via twisted +mccabe==0.6.1 + # via flake8 +mypy==0.931 + # via pika-stubs (setup.cfg) +mypy-extensions==0.4.3 + # via mypy +pika==1.2.0 + # via pika-stubs (setup.cfg) +pycodestyle==2.8.0 + # via flake8 +pyflakes==2.4.0 + # via + # flake8 + # flake8-pyi +six==1.16.0 + # via automat +tomli==2.0.0 + # via mypy +tornado==6.1 + # via pika-stubs (setup.cfg) +twisted==21.7.0 + # via pika-stubs (setup.cfg) +typing-extensions==4.0.1 + # via + # mypy + # twisted +zope.interface==5.4.0 + # via twisted + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/setup.cfg b/setup.cfg index 0aa77ea..ea75718 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,8 +25,9 @@ install_requires = [options.extras_require] dev = - flake8~=3.8.3 - mypy~=0.780 + flake8~=4.0.0 + flake8-pyi + mypy~=0.920 + pika==1.2.0 tornado twisted - gevent