summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Gateau <aurelien.gateau@gitguardian.com>2023-01-19 18:05:19 +0100
committerAsif Saif Uddin <auvipy@gmail.com>2023-02-02 20:14:19 +0600
commit08a997439d40245d56ee6f984857fadd3303ff7d (patch)
tree48f1e8c04d122688e5861fd70412df5577808171
parent16b8641c322f4cd6467e43583c7deaceb0cd9fd9 (diff)
downloadkombu-08a997439d40245d56ee6f984857fadd3303ff7d.tar.gz
Mark methods accepting Connection instances as such
In MaybeChannelBound, the `__call__()`, `bind()` and `maybe_bind()` methods takes a channel argument. The type annotation say this argument must be a Channel, but it goes through `maybe_channel()`, so it can also be a Connection. Update the annotation to accept both Channel and Connection.
-rw-r--r--kombu/abstract.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/kombu/abstract.py b/kombu/abstract.py
index 9bafba99..48a917c9 100644
--- a/kombu/abstract.py
+++ b/kombu/abstract.py
@@ -10,6 +10,7 @@ from .exceptions import NotBoundError
from .utils.functional import ChannelPromise
if TYPE_CHECKING:
+ from kombu.connection import Connection
from kombu.transport.virtual import Channel
@@ -80,19 +81,19 @@ class MaybeChannelBound(Object):
can_cache_declaration = False
def __call__(
- self: _MaybeChannelBoundType, channel: Channel
+ self: _MaybeChannelBoundType, channel: (Channel | Connection)
) -> _MaybeChannelBoundType:
"""`self(channel) -> self.bind(channel)`."""
return self.bind(channel)
def bind(
- self: _MaybeChannelBoundType, channel: Channel
+ self: _MaybeChannelBoundType, channel: (Channel | Connection)
) -> _MaybeChannelBoundType:
"""Create copy of the instance that is bound to a channel."""
return copy(self).maybe_bind(channel)
def maybe_bind(
- self: _MaybeChannelBoundType, channel: Channel
+ self: _MaybeChannelBoundType, channel: (Channel | Connection)
) -> _MaybeChannelBoundType:
"""Bind instance to channel if not already bound."""
if not self.is_bound and channel: