Skip to content

Commit 5d36ded

Browse files
authored
[SB] mypy + pylint fixes (#35310)
* pylint fixes * typo+mypy * line too long
1 parent afe3141 commit 5d36ded

16 files changed

+52
-30
lines changed

sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def _check_live(self):
385385
except AttributeError:
386386
pass
387387

388-
def _do_retryable_operation(
388+
def _do_retryable_operation( # pylint: disable=inconsistent-return-statements
389389
self,
390390
operation: Callable,
391391
timeout: Optional[float] = None,
@@ -496,13 +496,15 @@ def _mgmt_request_response(
496496
be service-specific, but common values include READ, CREATE and UPDATE.
497497
This value will be added as an application property on the message.
498498
:param message: The message to send in the management request.
499-
:paramtype message: Any
499+
:type message: Any
500500
:param callback: The callback which is used to parse the returning message.
501-
:paramtype callback: Callable[int, Union[~uamqp.message.Message, Message], str]
502-
:param keep_alive_associated_link: A boolean flag for keeping associated amqp sender/receiver link alive when
501+
:type callback: Callable[int, Union[~uamqp.message.Message, Message], str]
502+
:param bool keep_alive_associated_link: A boolean flag for keeping
503+
associated amqp sender/receiver link alive when
503504
executing operation on mgmt links.
504-
:param timeout: timeout in seconds executing the mgmt operation.
505-
:rtype: Tuple
505+
:param float or None timeout: timeout in seconds executing the mgmt operation.
506+
:return: The message response.
507+
:rtype: Message
506508
"""
507509
self._open()
508510
application_properties = {}

sdk/servicebus/azure-servicebus/azure/servicebus/_common/tracing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def trace_message(
241241
return message
242242

243243

244-
def get_receive_links(messages: Union[ReceiveMessageTypes, Iterable[ReceiveMessageTypes]]) -> List[Link]:
244+
def get_receive_links(messages: Union[ServiceBusReceivedMessage, Iterable[ServiceBusReceivedMessage]]) -> List[Link]:
245245
if not is_tracing_enabled():
246246
return []
247247

@@ -268,7 +268,8 @@ def get_receive_links(messages: Union[ReceiveMessageTypes, Iterable[ReceiveMessa
268268
if tracestate:
269269
headers["tracestate"] = cast(str, tracestate)
270270

271-
enqueued_time = message.raw_amqp_message.annotations.get(TRACE_ENQUEUED_TIME_PROPERTY)
271+
enqueued_time = message.raw_amqp_message.annotations.get(TRACE_ENQUEUED_TIME_PROPERTY) \
272+
if message.raw_amqp_message.annotations else None
272273
attributes = {SPAN_ENQUEUED_TIME_PROPERTY: enqueued_time} if enqueued_time else None
273274
links.append(Link(headers, attributes=attributes))
274275
except AttributeError:

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_client_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,8 @@ async def receive_message_batch_async(self, **kwargs):
844844
0, the client will continue to wait until at least one message is received. The
845845
default is 0.
846846
:paramtype timeout: float
847+
:return: Retryable operation coroutine.
848+
:rtype: Coroutine[Any, Any, Any]
847849
"""
848850
return await self._do_retryable_operation_async(
849851
self._receive_message_batch_impl_async,

sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ def from_connection_string(
236236
:keyword uamqp_transport: Whether to use the `uamqp` library as the underlying transport. The default value is
237237
False and the Pure Python AMQP library will be used as the underlying transport.
238238
:paramtype uamqp_transport: bool
239+
:returns: The ServiceBusClient instance.
239240
:rtype: ~azure.servicebus.ServiceBusClient
240241
241242
.. admonition:: Example:
@@ -383,6 +384,7 @@ def get_queue_receiver(
383384
wait when sending and receiving data before timing out. The default value is 0.2 for TransportType.Amqp
384385
and 1 for TransportType.AmqpOverWebsocket. If connection errors are occurring due to write timing out,
385386
a larger than default value may need to be passed in.
387+
:returns: The ServiceBusReceiver for the queue.
386388
:rtype: ~azure.servicebus.ServiceBusReceiver
387389
388390
.. admonition:: Example:

sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ def _from_connection_string(
325325
the in-memory prefetch buffer until they're received into the application. If the application ends before
326326
the messages are received into the application, those messages will be lost and unable to be recovered.
327327
Therefore, it's recommended that PEEK_LOCK mode be used with prefetch.
328+
:returns: The ServiceBusReceiver.
328329
:rtype: ~azure.servicebus.ServiceBusReceiver
329330
330331
:raises ~azure.servicebus.ServiceBusAuthenticationError: Indicates an issue in token/identity validity.

sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def _from_connection_string(cls, conn_str: str, **kwargs: Any) -> "ServiceBusSen
231231
keys: `'proxy_hostname'` (str value) and `'proxy_port'` (int value).
232232
Additionally the following keys may also be present: `'username', 'password'`.
233233
:keyword str user_agent: If specified, this will be added in front of the built-in user agent string.
234-
234+
:returns: The ServiceBusSender.
235235
:rtype: ~azure.servicebus.ServiceBusSender
236236
237237
:raises ~azure.servicebus.ServiceBusAuthenticationError: Indicates an issue in token/identity validity.

sdk/servicebus/azure-servicebus/azure/servicebus/_transport/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def create_mgmt_msg(
342342
):
343343
"""
344344
:param message: The message to send in the management request.
345-
:paramtype message: Any
345+
:type message: Any
346346
:param Dict[bytes, str] application_properties: App props.
347347
:param ~azure.servicebus._common._configuration.Configuration config: Configuration.
348348
:param str reply_to: Reply to.

sdk/servicebus/azure-servicebus/azure/servicebus/_transport/_pyamqp_transport.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,11 @@ def create_mgmt_msg(
903903
) -> "Message": # pylint:disable=unused-argument
904904
"""
905905
:param message: The message to send in the management request.
906-
:paramtype message: Any
906+
:type message: Any
907907
:param dict[bytes, str] application_properties: App props.
908908
:param ~azure.servicebus._common._configuration.Configuration config: Configuration.
909909
:param str reply_to: Reply to.
910+
:return: The message to send in the management request.
910911
:rtype: ~pyamqp.message.Message
911912
"""
912913
return Message(

sdk/servicebus/azure-servicebus/azure/servicebus/_transport/_uamqp_transport.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,11 @@ def send_messages(
605605
:param ~azure.servicebus.ServiceBusSender sender: The sender with handler
606606
to send messages.
607607
:param message: ServiceBusMessage with uamqp.Message to be sent.
608-
:paramtype message: ~azure.servicebus.ServiceBusMessage or ~azure.servicebus.ServiceBusMessageBatch
608+
:type message: ~azure.servicebus.ServiceBusMessage or ~azure.servicebus.ServiceBusMessageBatch
609609
:param int timeout: Timeout time.
610-
:param last_exception: Exception to raise if message timed out. Only used by uamqp transport.
611-
:param logger: Logger.
610+
:param Exception or None last_exception: Exception to raise if message timed out.
611+
Only used by uamqp transport.
612+
:param Logger logger: Logger.
612613
"""
613614
# pylint: disable=protected-access
614615
sender._open()
@@ -972,10 +973,11 @@ def create_mgmt_msg(
972973
) -> "Message":
973974
"""
974975
:param message: The message to send in the management request.
975-
:paramtype message: Any
976+
:type message: Any
976977
:param Dict[bytes, str] application_properties: App props.
977978
:param ~azure.servicebus._common._configuration.Configuration config: Configuration.
978979
:param str reply_to: Reply to.
980+
:return: The message to send in the management request.
979981
:rtype: uamqp.Message
980982
"""
981983
return Message( # type: ignore # TODO: fix mypy error

sdk/servicebus/azure-servicebus/azure/servicebus/aio/_base_handler_async.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,15 @@ async def _mgmt_request_response(
340340
be service-specific, but common values include READ, CREATE and UPDATE.
341341
This value will be added as an application property on the message.
342342
:param message: The message to send in the management request.
343-
:paramtype message: ~uamqp.message.Message
343+
:type message: ~uamqp.message.Message
344344
:param callback: The callback which is used to parse the returning message.
345-
:paramtype callback: Callable[int, ~uamqp.message.Message, str]
346-
:param keep_alive_associated_link: A boolean flag for keeping associated amqp sender/receiver link alive when
345+
:type callback: Callable[int, ~uamqp.message.Message, str]
346+
:param bool keep_alive_associated_link: A boolean flag for keeping
347+
associated amqp sender/receiver link alive when
347348
executing operation on mgmt links.
348-
:param timeout: timeout in seconds for executing the mgmt operation.
349-
:rtype: None
349+
:param float or None timeout: timeout in seconds for executing the mgmt operation.
350+
:return: The message response.
351+
:rtype: Message
350352
"""
351353
await self._open()
352354

0 commit comments

Comments
 (0)