Skip to content

Commit

Permalink
[Service Bus] Remove Six (Azure#27800)
Browse files Browse the repository at this point in the history
* remove six

* remove dependency
  • Loading branch information
kashifkhan committed Dec 2, 2022
1 parent 4b40de5 commit 4477d0d
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import logging
from typing import Optional, Dict, List, Union, Iterable, TYPE_CHECKING, Any, Mapping, cast

import six

import uamqp.errors
import uamqp.message

Expand Down Expand Up @@ -211,7 +209,7 @@ def __repr__(self):

def _build_message(self, body):
if not (
isinstance(body, (six.string_types, six.binary_type)) or (body is None)
isinstance(body, (str, bytes)) or (body is None)
):
raise TypeError(
"ServiceBusMessage body must be a string, bytes, or None. Got instead: {}".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import warnings
from typing import Any, List, Optional, Dict, Iterator, Union, TYPE_CHECKING, cast

import six

from uamqp import ReceiveClient, types, Message
from uamqp.constants import SenderSettleMode
from uamqp.authentication.common import AMQPAuth
Expand Down Expand Up @@ -728,7 +726,7 @@ def receive_deferred_messages(
self._check_live()
if timeout is not None and timeout <= 0:
raise ValueError("The timeout must be greater than 0.")
if isinstance(sequence_numbers, six.integer_types):
if isinstance(sequence_numbers, int):
sequence_numbers = [sequence_numbers]
sequence_numbers = cast(List[int], sequence_numbers)
if len(sequence_numbers) == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import datetime
import warnings
from typing import TYPE_CHECKING, Any, Union, Optional
import six

from ._common.utils import utc_from_timestamp, utc_now
from ._common.constants import (
Expand Down Expand Up @@ -146,7 +145,7 @@ def set_state(self, state: Union[str, bytes, bytearray], *, timeout: Optional[fl
if timeout is not None and timeout <= 0:
raise ValueError("The timeout must be greater than 0.")
state = (
state.encode(self._encoding) if isinstance(state, six.text_type) else state
state.encode(self._encoding) if isinstance(state, str) else state
)
return self._receiver._mgmt_request_response_with_retry( # type: ignore
REQUEST_RESPONSE_SET_SESSION_STATE_OPERATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import warnings
from typing import Any, List, Optional, AsyncIterator, Union, Callable, TYPE_CHECKING, cast

import six

from uamqp import ReceiveClientAsync, types, Message
from uamqp.constants import SenderSettleMode

Expand Down Expand Up @@ -695,7 +693,7 @@ async def receive_deferred_messages(
self._check_live()
if timeout is not None and timeout <= 0:
raise ValueError("The timeout must be greater than 0.")
if isinstance(sequence_numbers, six.integer_types):
if isinstance(sequence_numbers, int):
sequence_numbers = [sequence_numbers]
sequence_numbers = cast(List[int], sequence_numbers)
if len(sequence_numbers) == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import datetime
import warnings
from typing import Any, Union, Optional
import six

from .._servicebus_session import BaseSession
from .._common.constants import (
Expand Down Expand Up @@ -99,7 +98,7 @@ async def set_state(
if timeout is not None and timeout <= 0:
raise ValueError("The timeout must be greater than 0.")
state = (
state.encode(self._encoding) if isinstance(state, six.text_type) else state
state.encode(self._encoding) if isinstance(state, str) else state
)
return await self._receiver._mgmt_request_response_with_retry( # pylint: disable=protected-access
REQUEST_RESPONSE_SET_SESSION_STATE_OPERATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# --------------------------------------------------------------------------------------------

import time
import six
from azure.core.pipeline.policies import SansIOHTTPPolicy
from ...aio._base_handler_async import ServiceBusSharedKeyCredential

Expand All @@ -18,7 +17,7 @@ def __init__(
self._endpoint = endpoint
if not name:
raise ValueError("name can not be None or empty")
if not isinstance(name, six.string_types):
if not isinstance(name, str):
raise TypeError("name must be a string.")
self._name = name
self._token_expiry_on = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# --------------------------------------------------------------------------------------------

import time
import six
from azure.core.pipeline import PipelineRequest
from azure.core.pipeline.policies import SansIOHTTPPolicy
from .._base_handler import ServiceBusSharedKeyCredential
Expand All @@ -25,7 +24,7 @@ def __init__(self, endpoint, credential, name):
self._endpoint = endpoint
if not name:
raise ValueError("name can not be None or empty")
if not isinstance(name, six.string_types):
if not isinstance(name, str):
raise TypeError("name must be a string.")
self._name = name
self._token_expiry_on = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import TYPE_CHECKING, cast, Union, Mapping, Type, Any, Optional
from xml.etree.ElementTree import ElementTree, SubElement, QName
import isodate
import six

from . import _constants as constants
from ._api_version import DEFAULT_VERSION
Expand Down Expand Up @@ -123,9 +122,9 @@ def serialize_value_type(value):
value, bool
): # Attention: bool is subclass of int. So put bool ahead of int
return "boolean", str(value).lower()
if isinstance(value, six.string_types):
if isinstance(value, str):
return "string", value
if isinstance(value, six.integer_types):
if isinstance(value, int):
return "int" if value <= constants.INT32_MAX_VALUE else "long", str(value)
if isinstance(value, datetime):
return "dateTime", isodate.datetime_isoformat(value)
Expand Down
1 change: 0 additions & 1 deletion sdk/servicebus/azure-servicebus/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
'msrest>=0.6.17,<2.0.0',
'azure-core<2.0.0,>=1.14.0',
"isodate>=0.6.0",
"six>=1.11.0",
"typing-extensions>=3.7.4.3",
]
)

0 comments on commit 4477d0d

Please sign in to comment.