From 04adc14a204104f9833a6f35736c42c114ab5925 Mon Sep 17 00:00:00 2001 From: "emily.gelfand" Date: Wed, 7 Oct 2020 20:50:18 -0700 Subject: [PATCH 1/3] replaced references to internal _accesstoken with the accesstoken itself, now that its available --- .../azure-servicebus/azure/servicebus/_base_handler.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py index 545fa074807f..6367beab6cf7 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py @@ -38,7 +38,6 @@ if TYPE_CHECKING: from azure.core.credentials import TokenCredential -_AccessToken = collections.namedtuple("AccessToken", "token expires_on") _LOGGER = logging.getLogger(__name__) @@ -108,7 +107,7 @@ def _generate_sas_token(uri, policy, key, expiry=None): encoded_key = key.encode("utf-8") token = utils.create_sas_token(encoded_policy, encoded_key, encoded_uri, expiry) - return _AccessToken(token=token, expires_on=abs_expiry) + return AccessToken(token=token, expires_on=abs_expiry) class ServiceBusSASTokenCredential(object): From e06d03ce2316812b68e346dd6a38b661dd63379c Mon Sep 17 00:00:00 2001 From: "emily.gelfand" Date: Mon, 26 Oct 2020 23:59:20 -0700 Subject: [PATCH 2/3] Further replaced references to internal _Accesstoken with Accesstoken itself. --- .../azure/servicebus/aio/_base_handler_async.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_base_handler_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_base_handler_async.py index d6fb5d3722aa..e7e204160b43 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_base_handler_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_base_handler_async.py @@ -12,7 +12,7 @@ from azure.core.credentials import AccessToken -from .._base_handler import _generate_sas_token, _AccessToken, BaseHandler as BaseHandlerSync +from .._base_handler import _generate_sas_token, BaseHandler as BaseHandlerSync from .._common._configuration import Configuration from .._common.utils import create_properties from .._common.constants import ( @@ -64,7 +64,7 @@ def __init__(self, policy: str, key: str) -> None: self.key = key self.token_type = TOKEN_TYPE_SASTOKEN - async def get_token(self, *scopes: str, **kwargs: Any) -> _AccessToken: # pylint:disable=unused-argument + async def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken: # pylint:disable=unused-argument if not scopes: raise ValueError("No token scope provided.") return _generate_sas_token(scopes[0], self.policy, self.key) From 77c647cd2087267a8564d622a1239d8f2cc806ff Mon Sep 17 00:00:00 2001 From: "emily.gelfand" Date: Fri, 30 Oct 2020 00:26:00 -0700 Subject: [PATCH 3/3] Corrected mypy/pylint errors --- .../azure-servicebus/azure/servicebus/_base_handler.py | 5 ++--- .../azure-servicebus/azure/servicebus/exceptions.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py index 09b3c04adce6..dc84504b29db 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_base_handler.py @@ -2,7 +2,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -import collections import logging import uuid import time @@ -94,7 +93,7 @@ def _parse_conn_str(conn_str): def _generate_sas_token(uri, policy, key, expiry=None): - # type: (str, str, str, Optional[timedelta]) -> _AccessToken + # type: (str, str, str, Optional[timedelta]) -> AccessToken """Create a shared access signiture token as a string literal. :returns: SAS token as string literal. :rtype: str @@ -148,7 +147,7 @@ def __init__(self, policy, key): self.token_type = TOKEN_TYPE_SASTOKEN def get_token(self, *scopes, **kwargs): # pylint:disable=unused-argument - # type: (str, Any) -> _AccessToken + # type: (str, Any) -> AccessToken if not scopes: raise ValueError("No token scope provided.") return _generate_sas_token(scopes[0], self.policy, self.key) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py b/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py index d1bb0ab66e80..ba07eb19ec11 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from typing import Optional, Any +from typing import Optional from uamqp import errors, constants from azure.core.exceptions import AzureError