Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServiceBus] fix typehints #23856

Merged
5 commits merged into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def register(
:type receiver: ~azure.servicebus.ServiceBusReceiver
: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).
:param max_lock_renewal_duration: A time in seconds that the lock should be maintained for. If set to None,
`max_lock_renewal_duration` value passed to constructor will be used. Default value is None.
swathipil marked this conversation as resolved.
Show resolved Hide resolved
: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 @@ -70,7 +70,7 @@ 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 Optional[Dict[str, Any]] application_properties: The user defined properties on the message.
swathipil marked this conversation as resolved.
Show resolved Hide resolved
: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
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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class ServiceBusError(AzureError):
:ivar str message: A stringified version of the message parameter
"""

def __init__(self, message, *args, **kwargs):
def __init__(self, message: str, *args, **kwargs):
self._retryable = kwargs.pop("retryable", False)
self._shutdown_handler = kwargs.pop("shutdown_handler", True)
self._condition = kwargs.pop("condition", None)
Expand Down