Skip to content

Commit

Permalink
[ServiceBus] fix typehints (Azure#23856)
Browse files Browse the repository at this point in the history
  • Loading branch information
swathipil authored Apr 7, 2022
1 parent bd33762 commit 685d06f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def register(
:param renewable: A locked entity that needs to be renewed.
:type renewable: Union[~azure.servicebus.ServiceBusReceivedMessage, ~azure.servicebus.ServiceBusSession]
:param max_lock_renewal_duration: A time in seconds that the lock should be maintained for.
Default value is 300 (5 minutes).
Default value is None. If specified, this value will override the default value specified at the constructor.
:type max_lock_renewal_duration: Optional[float]
:param on_lock_renew_failure: A callback may be specified to be called when the lock is lost on the renewable
that is being registered. Default value is None (no callback).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
)
from .._servicebus_receiver import ServiceBusReceiver
from azure.core.tracing import AbstractSpan
PrimitiveTypes = Union[
int,
float,
bytes,
bool,
str,
uuid.UUID
]

_LOGGER = logging.getLogger(__name__)

Expand All @@ -70,7 +78,9 @@ class ServiceBusMessage(
:param body: The data to send in a single message.
:type body: Optional[Union[str, bytes]]
:keyword Optional[Dict] application_properties: The user defined properties on the message.
:keyword application_properties: The user defined properties on the message.
:paramtype application_properties: Dict[str, Union[int or float or bool or
bytes or str or uuid.UUID or datetime or None]]
:keyword Optional[str] session_id: The session identifier of the message for a sessionful entity.
:keyword Optional[str] message_id: The id to identify the message.
:keyword Optional[datetime.datetime] scheduled_enqueue_time_utc: The utc scheduled enqueue time to the message.
Expand Down Expand Up @@ -98,7 +108,7 @@ def __init__(
self,
body: Optional[Union[str, bytes]],
*,
application_properties: Optional[Dict[str, Any]] = None,
application_properties: Optional[Dict[str, "PrimitiveTypes"]] = None,
session_id: Optional[str] = None,
message_id: Optional[str] = None,
scheduled_enqueue_time_utc: Optional[datetime.datetime] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class ServiceBusClient(object):
:keyword float retry_backoff_factor: Delta back-off internal in the unit of second between retries.
Default value is 0.8.
:keyword float retry_backoff_max: Maximum back-off interval in the unit of second. Default value is 120.
:keyword retry_mode: The delay behavior between retry attempts. Supported values are 'fixed' or 'exponential',
where default is 'exponential'.
:keyword retry_mode: The delay behavior between retry attempts. Supported values are "fixed" or "exponential",
where default is "exponential".
:paramtype retry_mode: str
.. admonition:: Example:
Expand All @@ -97,7 +97,7 @@ def __init__(
*,
retry_total: int = 3,
retry_backoff_factor: float = 0.8,
retry_backoff_max: int = 120,
retry_backoff_max: float = 120,
retry_mode: str = "exponential",
**kwargs: Any
) -> None:
Expand Down Expand Up @@ -290,13 +290,12 @@ def get_queue_receiver(
sessionful queue, otherwise it must be None. In order to receive messages from the next available
session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION.
:paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION
:keyword sub_queue: If specified, the subqueue this receiver will
connect to.
:keyword sub_queue: If specified, the subqueue this receiver will connect to.
This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any
receiver or messages that can't be processed.
The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue`
enum or equivalent string values "deadletter" and "transferdeadletter".
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None
:keyword receive_mode: The receive_mode with which messages will be retrieved from the entity. The two options
are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given
lock period before they will be removed from the queue. Messages received with RECEIVE_AND_DELETE
Expand Down Expand Up @@ -445,13 +444,12 @@ def get_subscription_receiver(
sessionful subscription, otherwise it must be None. In order to receive messages from the next available
session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION.
:paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION
:keyword sub_queue: If specified, the subqueue this receiver will
connect to.
:keyword sub_queue: If specified, the subqueue this receiver will connect to.
This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any
receiver or messages that can't be processed.
The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue`
enum or equivalent string values "deadletter" and "transferdeadletter".
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None
:keyword receive_mode: The receive_mode with which messages will be retrieved from the entity. The two options
are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given
lock period before they will be removed from the subscription. Messages received with RECEIVE_AND_DELETE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@


class BaseSession(object):
def __init__(self, session_id, receiver):
# type: (str, Union[ServiceBusReceiver, ServiceBusReceiverAsync]) -> None
def __init__(self, session_id: str, receiver: Union["ServiceBusReceiver", "ServiceBusReceiverAsync"]) -> None:
self._session_id = session_id
self._receiver = receiver
self._encoding = "UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def register(
:type receiver: ~azure.servicebus.aio.ServiceBusReceiver
:param renewable: A locked entity that needs to be renewed.
:type renewable: Union[~azure.servicebus.aio.ServiceBusReceivedMessage,~azure.servicebus.aio.ServiceBusSession]
:param max_lock_renewal_duration: A time in seconds that locks registered to this renewer
should be maintained for. Default value is 300 (5 minutes).
:param max_lock_renewal_duration: A time in seconds that the lock should be maintained for.
Default value is None. If specified, this value will override the default value specified at the constructor.
:type max_lock_renewal_duration: Optional[float]
:param Optional[AsyncLockRenewFailureCallback] on_lock_renew_failure:
An async callback may be specified to be called when the lock is lost on the renewable being registered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class ServiceBusClient(object):
:keyword float retry_backoff_factor: Delta back-off internal in the unit of second between retries.
Default value is 0.8.
:keyword float retry_backoff_max: Maximum back-off interval in the unit of second. Default value is 120.
:keyword retry_mode: The delay behavior between retry attempts. Supported values are 'fixed' or 'exponential',
where default is 'exponential'.
:keyword retry_mode: The delay behavior between retry attempts. Supported values are "fixed" or "exponential",
where default is "exponential".
:paramtype retry_mode: str
.. admonition:: Example:
Expand All @@ -90,8 +90,8 @@ def __init__(
*,
retry_total: int = 3,
retry_backoff_factor: float = 0.8,
retry_backoff_max: int = 120,
retry_mode: str = 'exponential',
retry_backoff_max: float = 120,
retry_mode: str = "exponential",
**kwargs: Any
) -> None:
# If the user provided http:// or sb://, let's be polite and strip that.
Expand Down Expand Up @@ -278,14 +278,13 @@ def get_queue_receiver(
:keyword session_id: A specific session from which to receive. This must be specified for a
sessionful queue, otherwise it must be None. In order to receive messages from the next available
session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION.
:paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION
:keyword sub_queue: If specified, the subqueue this receiver will
connect to.
:paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION or None
:keyword sub_queue: If specified, the subqueue this receiver will connect to.
This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any
receiver or messages that can't be processed.
The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue`
enum or equivalent string values "deadletter" and "transferdeadletter".
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None
:keyword receive_mode: The mode with which messages will be retrieved from the entity. The two options
are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given
lock period before they will be removed from the queue. Messages received with RECEIVE_AND_DELETE
Expand Down Expand Up @@ -431,14 +430,13 @@ def get_subscription_receiver(
:keyword session_id: A specific session from which to receive. This must be specified for a
sessionful subscription, otherwise it must be None. In order to receive messages from the next available
session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION.
:paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION
:keyword sub_queue: If specified, the subqueue this receiver will
connect to.
:paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION or None
:keyword sub_queue: If specified, the subqueue this receiver will connect to.
This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any
receiver or messages that can't be processed.
The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue`
enum or equivalent string values "deadletter" and "transferdeadletter".
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue
:paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None
:keyword receive_mode: The mode with which messages will be retrieved from the entity. The two options
are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given
lock period before they will be removed from the subscription. Messages received with RECEIVE_AND_DELETE
Expand Down

0 comments on commit 685d06f

Please sign in to comment.