Skip to content

Commit ae4f530

Browse files
[SB] next-pylint (Azure#38860)
* next-pylint * pylint * pylint2 * remove diff * nit * fix * kashif * mypy * Update sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/utils.py Co-authored-by: Kashif Khan <[email protected]> * Revert "Update sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/utils.py" This reverts commit 85b80d4. * fix * fix --------- Co-authored-by: Kashif Khan <[email protected]>
1 parent 9b941a1 commit ae4f530

38 files changed

+166
-178
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from .exceptions import ServiceBusError
3939

4040
try:
41-
# pylint:disable=unused-import
4241
from uamqp import AMQPClient as uamqp_AMQPClientSync
4342
except ImportError:
4443
pass
@@ -372,7 +371,6 @@ def _check_live(self):
372371
def _do_retryable_operation( # pylint: disable=inconsistent-return-statements
373372
self, operation: Callable, timeout: Optional[float] = None, **kwargs: Any
374373
) -> Any:
375-
# pylint: disable=protected-access
376374
require_last_exception = kwargs.pop("require_last_exception", False)
377375
operation_requires_timeout = kwargs.pop("operation_requires_timeout", False)
378376
retried_times = 0
@@ -435,7 +433,7 @@ def _backoff(
435433
)
436434
if backoff <= self._config.retry_backoff_max and (
437435
abs_timeout_time is None or (backoff + time.time()) <= abs_timeout_time
438-
): # pylint:disable=no-else-return
436+
):
439437
time.sleep(backoff)
440438
_LOGGER.info(
441439
"%r has an exception (%r). Retrying...",
@@ -517,7 +515,7 @@ def _mgmt_request_response(
517515
timeout=timeout,
518516
callback=callback,
519517
)
520-
except Exception as exp: # pylint: disable=broad-except
518+
except Exception as exp:
521519
if isinstance(exp, self._amqp_transport.TIMEOUT_ERROR):
522520
raise OperationTimeoutError(error=exp) from exp
523521
raise

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
if TYPE_CHECKING:
4949
try:
50-
# pylint:disable=unused-import
5150
from uamqp import Message, BatchMessage
5251
except ImportError:
5352
pass
@@ -59,7 +58,7 @@
5958
PrimitiveTypes = Union[int, float, bytes, bool, str, uuid.UUID]
6059

6160

62-
class ServiceBusMessage(object): # pylint: disable=too-many-public-methods,too-many-instance-attributes
61+
class ServiceBusMessage(object): # pylint: disable=too-many-instance-attributes
6362
"""A Service Bus Message.
6463
6564
:param body: The data to send in a single message.
@@ -671,7 +670,7 @@ def _add(self, add_message: Union[ServiceBusMessage, Mapping[str, Any], AmqpAnno
671670
raise MessageSizeExceededError(
672671
message=f"ServiceBusMessageBatch has reached its size limit: {self.max_size_in_bytes}"
673672
)
674-
self._amqp_transport.add_batch(self, outgoing_sb_message) # pylint: disable=protected-access
673+
self._amqp_transport.add_batch(self, outgoing_sb_message)
675674
self._size = size_after_add
676675
self._count += 1
677676
self._messages.append(outgoing_sb_message)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def default(status_code, message, description, amqp_transport): # pylint: disab
1717
if status_code == 200:
1818
return message.value
1919

20-
amqp_transport.handle_amqp_mgmt_error( # pylint: disable=protected-access
20+
amqp_transport.handle_amqp_mgmt_error(
2121
_LOGGER, "Service request failed.", condition, description, status_code
2222
)
2323

@@ -29,7 +29,7 @@ def session_lock_renew_op( # pylint: disable=inconsistent-return-statements
2929
if status_code == 200:
3030
return message.value
3131

32-
amqp_transport.handle_amqp_mgmt_error( # pylint: disable=protected-access
32+
amqp_transport.handle_amqp_mgmt_error(
3333
_LOGGER, "Session lock renew failed.", condition, description, status_code
3434
)
3535

@@ -42,7 +42,7 @@ def message_lock_renew_op( # pylint: disable=inconsistent-return-statements
4242
# TODO: will this always be body type ValueType?
4343
return message.value
4444

45-
amqp_transport.handle_amqp_mgmt_error( # pylint: disable=protected-access
45+
amqp_transport.handle_amqp_mgmt_error(
4646
_LOGGER, "Message lock renew failed.", condition, description, status_code
4747
)
4848

@@ -58,7 +58,7 @@ def peek_op( # pylint: disable=inconsistent-return-statements
5858
if status_code in [202, 204]:
5959
return []
6060

61-
amqp_transport.handle_amqp_mgmt_error( # pylint: disable=protected-access
61+
amqp_transport.handle_amqp_mgmt_error(
6262
_LOGGER, "Message peek failed.", condition, description, status_code
6363
)
6464

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ def _populate_attributes(self, **kwargs):
6767
)
6868

6969
def _get_source(self):
70-
# pylint: disable=protected-access
7170
if self._session:
7271
session_filter = None if self._session_id == NEXT_AVAILABLE_SESSION else self._session_id
7372
return self._amqp_transport.create_source(self._entity_uri, session_filter)
7473
return self._entity_uri
7574

7675
def _check_message_alive(self, message, action):
77-
# pylint: disable=no-member, protected-access
76+
# pylint: disable=protected-access
7877
if message._is_peeked_message:
7978
raise ValueError(
8079
f"The operation {action} is not supported for peeked messages."

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
if TYPE_CHECKING:
2727
try:
28-
# pylint:disable=unused-import
2928
from uamqp import Message as uamqp_Message
3029
except ImportError:
3130
uamqp_Message = None
@@ -229,7 +228,7 @@ def get_receive_links(messages: Union[ServiceBusReceivedMessage, Iterable[Servic
229228

230229
trace_messages = (
231230
messages
232-
if isinstance(messages, Iterable) # pylint:disable=isinstance-second-argument-not-valid-type
231+
if isinstance(messages, Iterable)
233232
else (messages,)
234233
)
235234

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
if TYPE_CHECKING:
4444
try:
45-
# pylint:disable=unused-import
4645
from uamqp import types as uamqp_types
4746
from uamqp.authentication import JWTTokenAuth as uamqp_JWTTokenAuth
4847
except ImportError:
@@ -95,6 +94,9 @@ def create_properties(
9594
:param str user_agent: If specified,
9695
this will be added in front of the built-in user agent string.
9796
97+
:keyword amqp_transport: The AMQP transport type.
98+
:paramtype amqp_transport: ~azure.servicebus._transport._base.AmqpTransport
99+
98100
:return: The properties to add to the connection.
99101
:rtype: dict
100102
"""
@@ -131,7 +133,6 @@ def get_renewable_start_time(renewable):
131133

132134

133135
def get_renewable_lock_duration(renewable: Union["ServiceBusReceivedMessage", "BaseSession"]) -> datetime.timedelta:
134-
# pylint: disable=protected-access
135136
try:
136137
return max(renewable.locked_until_utc - utc_now(), datetime.timedelta(seconds=0))
137138
except AttributeError:

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Connection: # pylint:disable=too-many-instance-attributes
9090
and 1 for transport type AmqpOverWebsocket.
9191
"""
9292

93-
def __init__( # pylint:disable=too-many-locals,too-many-statements
93+
def __init__( # pylint:disable=too-many-locals
9494
self,
9595
endpoint: str,
9696
*,

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_decode.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
# pylint: disable=redefined-builtin, import-error
7-
86
import struct
97
import uuid
108
import logging

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_encode.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,9 @@ def encode_map(
489489
count = len(cast(Sized, value)) * 2
490490
encoded_size = 0
491491
encoded_values = bytearray()
492+
items: Iterable[Any]
492493
if isinstance(value, dict):
493-
items: Iterable[Any] = value.items()
494+
items = value.items()
494495
elif isinstance(value, Iterable):
495496
items = value
496497

sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_message_backcompat.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
7-
# pylint: disable=too-many-lines
86
from enum import Enum
97
from typing import (
108
Callable,

0 commit comments

Comments
 (0)