From 88a742c94030258dd2a23ff44464a7220934f289 Mon Sep 17 00:00:00 2001 From: Sean Kane <68240067+seankane-msft@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:23:14 -0400 Subject: [PATCH] [Tables] updating docstring (#19547) --- .../azure-data-tables/azure/data/tables/_base_client.py | 6 ++++-- .../azure/data/tables/aio/_base_client_async.py | 9 ++++++--- .../azure/data/tables/aio/_table_client_async.py | 7 +++++-- .../azure/data/tables/aio/_table_service_client_async.py | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py index f18a8100bc46..58c83d844b96 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- -from typing import Dict, Optional, Any, List, Mapping, Union +from typing import Dict, Optional, Any, List, Mapping, Union, TYPE_CHECKING from uuid import uuid4 try: from urllib.parse import parse_qs, quote, urlparse @@ -50,6 +50,8 @@ ) from ._sdk_moniker import SDK_MONIKER +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential _SUPPORTED_API_VERSIONS = ["2019-02-02", "2019-07-07"] @@ -71,7 +73,7 @@ class AccountHostsMixin(object): # pylint: disable=too-many-instance-attributes def __init__( self, account_url, # type: Any - credential=None, # type: Optional[Union[AzureNamedKeyCredential, AzureSasCredential]] + credential=None, # type: Optional[Union[AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py index a7a0c5212154..06b3136394d1 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- -from typing import Any, List, Mapping, Optional, Union +from typing import Any, List, Mapping, Optional, Union, TYPE_CHECKING from uuid import uuid4 from azure.core.credentials import AzureSasCredential, AzureNamedKeyCredential @@ -35,6 +35,9 @@ from .._sdk_moniker import SDK_MONIKER from ._policies_async import AsyncTablesRetryPolicy +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + class AsyncTablesBaseClient(AccountHostsMixin): @@ -42,10 +45,10 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self, endpoint: str, *, - credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential]] = None, + credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential, "AsyncTokenCredential"]] = None, **kwargs: Any ) -> None: - super(AsyncTablesBaseClient, self).__init__(endpoint, credential=credential, **kwargs) + super(AsyncTablesBaseClient, self).__init__(endpoint, credential=credential, **kwargs) # type: ignore self._client = AzureTable( self.url, policies=kwargs.pop('policies', self._policies), diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py index 61139d8b897f..4513b657d9ef 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from typing import List, Union, Any, Optional, Mapping, Iterable, Dict, overload, cast +from typing import List, Union, Any, Optional, Mapping, Iterable, Dict, overload, cast, TYPE_CHECKING try: from urllib.parse import urlparse, unquote except ImportError: @@ -38,6 +38,9 @@ from ._models import TableEntityPropertiesPaged from ._table_batch_async import TableBatchOperations +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + class TableClient(AsyncTablesBaseClient): """A client to interact with a specific Table in an Azure Tables account. @@ -52,7 +55,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential endpoint: str, table_name: str, *, - credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential]] = None, + credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential, "AsyncTokenCredential"]] = None, **kwargs ) -> None: """Create TableClient from a Credential. diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py index c6ad7a64b618..ba5282a1f7ec 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py @@ -326,7 +326,7 @@ def get_table_client(self, table_name: str, **kwargs) -> TableClient: return TableClient( self.url, table_name=table_name, - credential=self.credential, + credential=self.credential, # type: ignore api_version=self.api_version, pipeline=pipeline, location_mode=self._location_mode,