Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tables] updating docstring #19547

Merged
3 commits merged into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -35,17 +35,20 @@
from .._sdk_moniker import SDK_MONIKER
from ._policies_async import AsyncTablesRetryPolicy

if TYPE_CHECKING:
from azure.core.credentials_async import AsyncTokenCredential


class AsyncTablesBaseClient(AccountHostsMixin):

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a problem that we are passing an async credential policy into the parent base_client constructor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this gets passed all the way down to AccountHostsMixin which expects a sync token credential.

self._client = AzureTable(
self.url,
policies=kwargs.pop('policies', self._policies),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to suppress the type here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AccountHostsMixin expects a sync token credential.

api_version=self.api_version,
pipeline=pipeline,
location_mode=self._location_mode,
Expand Down