Skip to content

Commit 2b39a4f

Browse files
committed
had to fix fomratting of async docstring types
1 parent 5347710 commit 2b39a4f

File tree

4 files changed

+129
-122
lines changed

4 files changed

+129
-122
lines changed

sdk/tables/azure-data-tables/azure/data/tables/aio/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
'TableClient',
1212
'TableServiceClient',
1313
]
14-

sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
from enum import Enum
7-
86
from azure.data.tables._deserialize import _convert_to_entity
9-
from azure.data.tables._shared.models import Services
107
from azure.data.tables._shared.response_handlers import return_context_and_deserialized, process_table_error
118
from azure.core.exceptions import HttpResponseError
129
from azure.core.async_paging import AsyncPageIterator

sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py

Lines changed: 90 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
16
import functools
27
from typing import (
3-
Union,
4-
Optional,
8+
Union,
59
Any,
6-
Dict,
7-
List
810
)
911

1012
from azure.core.async_paging import AsyncItemPaged
@@ -14,69 +16,64 @@
1416
from azure.data.tables import VERSION
1517
from azure.data.tables._entity import TableEntity
1618
from azure.data.tables._generated.aio._azure_table_async import AzureTable
17-
from azure.data.tables._generated.models import SignedIdentifier, TableProperties, QueryOptions, TableServiceProperties
19+
from azure.data.tables._generated.models import SignedIdentifier, TableProperties, QueryOptions
1820
from azure.data.tables._models import AccessPolicy
19-
from azure.data.tables._shared.base_client import parse_connection_str
2021
from azure.data.tables._shared.base_client_async import AsyncStorageAccountHostsMixin
2122
from azure.data.tables._shared.policies_async import ExponentialRetry
2223
from azure.data.tables._shared.request_handlers import serialize_iso
2324
from azure.data.tables._shared.response_handlers import return_headers_and_deserialized, process_table_error
2425

25-
from .._models import UpdateMode
26+
from .._models import UpdateMode
2627
from ._models import TableEntityPropertiesPaged
2728
from .._deserialize import _convert_to_entity
2829
from .._serialize import _add_entity_properties, _get_match_headers
2930
from .._shared._table_client_base import TableClientBase
3031

3132

3233
class TableClient(AsyncStorageAccountHostsMixin, TableClientBase):
33-
"""A client to interact with a specific Queue.
34-
35-
:param str account_url:
36-
The URL to the storage account. In order to create a client given the full URI to the queue,
37-
use the :func:`from_queue_url` classmethod.
38-
:param queue_name: The name of the queue.
39-
:type queue_name: str
40-
:param credential:
41-
The credentials with which to authenticate. This is optional if the
42-
account URL already has a SAS token. The value can be a SAS token string, an account
43-
shared access key.
44-
:keyword str api_version:
45-
The Storage API version to use for requests. Default value is '2019-07-07'.
46-
Setting to an older version may result in reduced feature compatibility.
47-
:keyword str secondary_hostname:
48-
The hostname of the secondary endpoint.
49-
:keyword message_encode_policy: The encoding policy to use on outgoing messages.
50-
Default is not to encode messages. Other options include :class:`TextBase64EncodePolicy`,
51-
:class:`BinaryBase64EncodePolicy` or `None`.
52-
:keyword message_decode_policy: The decoding policy to use on incoming messages.
53-
Default value is not to decode messages. Other options include :class:`TextBase64DecodePolicy`,
54-
:class:`BinaryBase64DecodePolicy` or `None`.
55-
56-
"""
34+
""" :ivar str account_name: Name of the storage account (Cosmos or Azure)"""
5735

5836
def __init__(
5937
self,
60-
account_url: str,
61-
table_name: str,
62-
credential: Optional[Any]=None,
63-
**kwargs: Any
64-
) -> None:
38+
account_url, # type: str
39+
table_name, # type: str
40+
credential, # type : Optional[Any]=None
41+
**kwargs # type: Any
42+
):
43+
# type: (...) -> None
44+
"""Create TableClient from a Credential.
45+
46+
:param account_url:
47+
A url to an Azure Storage account.
48+
:type account_url: str
49+
:param table_name: The table name.
50+
:type table_name: str
51+
:param credential:
52+
The credentials with which to authenticate. This is optional if the
53+
account URL already has a SAS token, or the connection string already has shared
54+
access key values. The value can be a SAS token string, an account shared access
55+
key, or an instance of a TokenCredentials class from azure.identity.
56+
:type credential: Union[str,TokenCredential]
57+
58+
:returns: None
59+
"""
6560
kwargs["retry_policy"] = kwargs.get("retry_policy") or ExponentialRetry(**kwargs)
6661
loop = kwargs.pop('loop', None)
6762
super(TableClient, self).__init__(
6863
account_url, table_name=table_name, credential=credential, loop=loop, **kwargs
6964
)
7065
self._client = AzureTable(self.url, pipeline=self._pipeline, loop=loop)
71-
self._client._config.version = kwargs.get('api_version', VERSION)
66+
self._client._config.version = kwargs.get('api_version', VERSION) # pylint: disable = W0212
7267
self._loop = loop
7368

7469
@distributed_trace_async
7570
async def get_table_access_policy(
7671
self,
77-
**kwargs: Any
78-
) -> Dict[str,AccessPolicy]:
79-
"""Retrieves details about any stored access policies specified on the table that may be
72+
**kwargs # type: Any
73+
):
74+
# type: (...) -> dict[str,AccessPolicy]
75+
"""
76+
Retrieves details about any stored access policies specified on the table that may be
8077
used with Shared Access Signatures.
8178
:return: Dictionary of SignedIdentifiers
8279
:rtype: dict[str,~azure.data.tables.AccessPolicy]
@@ -126,8 +123,9 @@ async def set_table_access_policy(
126123
@distributed_trace_async
127124
async def create_table(
128125
self,
129-
**kwargs: Any
130-
) -> str:
126+
**kwargs # type: Any
127+
):
128+
# type: (...) -> str
131129
"""Creates a new table under the given account.
132130
:return: Table created
133131
:rtype: str
@@ -140,8 +138,9 @@ async def create_table(
140138
@distributed_trace_async
141139
async def delete_table(
142140
self,
143-
**kwargs: Any
144-
) -> None:
141+
**kwargs # type: Any
142+
):
143+
# type: (...) -> None
145144
"""Creates a new table under the given account.
146145
:return: None
147146
:rtype: None
@@ -151,10 +150,11 @@ async def delete_table(
151150
@distributed_trace_async
152151
async def delete_entity(
153152
self,
154-
partition_key: str,
155-
row_key: str,
156-
**kwargs: Any
157-
) -> None:
153+
partition_key, # type: str
154+
row_key, # type: str
155+
**kwargs # type: Any
156+
):
157+
# type: (...) -> None
158158
"""Deletes the specified entity in a table.
159159
:param partition_key: The partition key of the entity.
160160
:type partition_key: str
@@ -168,7 +168,7 @@ async def delete_entity(
168168
"""
169169
if_match, if_not_match = _get_match_headers(kwargs=dict(kwargs, etag=kwargs.pop('etag', None),
170170
match_condition=kwargs.pop('match_condition', None)),
171-
etag_param='etag', match_param='match_condition')
171+
etag_param='etag', match_param='match_condition')
172172

173173
await self._client.table.delete_entity(
174174
table=self.table_name,
@@ -180,9 +180,10 @@ async def delete_entity(
180180
@distributed_trace_async
181181
async def create_entity(
182182
self,
183-
entity: Dict[str,str],
184-
**kwargs: Any
185-
) -> Union[Dict[str,str], TableEntity]:
183+
entity, # type: Union[TableEntity, dict[str,str]]
184+
**kwargs # type: Any
185+
):
186+
# type: (...) -> TableEntity
186187
"""Insert entity in a table.
187188
:param entity: The properties for the table entity.
188189
:type entity: dict[str, str]
@@ -203,17 +204,18 @@ async def create_entity(
203204
**kwargs
204205
)
205206
properties = _convert_to_entity(inserted_entity)
206-
return properties
207-
except ResourceNotFoundError as error:
207+
return properties
208+
except ResourceNotFoundError as error:
208209
process_table_error(error)
209210

210211
@distributed_trace_async
211-
async def update_entity(
212+
async def update_entity(
212213
self,
213-
entity: Dict[str,str],
214-
mode: UpdateMode=UpdateMode.MERGE,
215-
**kwargs: Any
216-
) -> None:
214+
entity, # type: Union[TableEntity, dict[str,str]]
215+
mode=UpdateMode.MERGE, # type: UpdateMode
216+
**kwargs # type: Any
217+
):
218+
# type: (...) -> None
217219
"""Update entity in a table.
218220
:param mode: Merge or Replace entity
219221
:type mode: ~azure.data.tables.UpdateMode
@@ -231,8 +233,8 @@ async def update_entity(
231233
:rtype: None
232234
:raises: ~azure.core.exceptions.HttpResponseError
233235
"""
234-
if_match, if_not_match = _get_match_headers(kwargs=dict(kwargs, etag=kwargs.pop('etag', None),
235-
match_condition=kwargs.pop('match_condition', None)),
236+
if_match, if_not_match = _get_match_headers(kwargs=dict(kwargs, etag=kwargs.pop('etag', None),
237+
match_condition=kwargs.pop('match_condition', None)),
236238
etag_param='etag', match_param='match_condition')
237239

238240
partition_key = entity['PartitionKey']
@@ -256,9 +258,10 @@ async def update_entity(
256258

257259
@distributed_trace
258260
def list_entities(
259-
self,
260-
**kwargs: Any
261-
) -> AsyncItemPaged[TableEntity]:
261+
self,
262+
**kwargs # type: Any
263+
):
264+
# type: (...) -> AsyncItemPaged[TableEntity]
262265
"""Lists entities in a table.
263266
264267
:keyword int results_per_page: Number of entities per page in return ItemPaged
@@ -284,9 +287,10 @@ def list_entities(
284287
@distributed_trace
285288
def query_entities(
286289
self,
287-
filter: List[str],
288-
**kwargs: Any
289-
) -> AsyncItemPaged[TableEntity]:
290+
filter, # type: str # pylint: disable = W0622
291+
**kwargs
292+
):
293+
# type: (...) -> AsyncItemPaged[TableEntity]
290294
"""Lists entities in a table.
291295
292296
:param str filter: Specify a filter to return certain entities
@@ -298,7 +302,7 @@ def query_entities(
298302
:raises: ~azure.core.exceptions.HttpResponseError
299303
"""
300304
parameters = kwargs.pop('parameters', None)
301-
filter = self._parameter_filter_substitution(parameters, filter) # pylint: disable = W0622
305+
filter = self._parameter_filter_substitution(parameters, filter) # pylint: disable = W0622
302306

303307
user_select = kwargs.pop('select', None)
304308
if user_select and not isinstance(user_select, str):
@@ -319,10 +323,11 @@ def query_entities(
319323
@distributed_trace_async
320324
async def get_entity(
321325
self,
322-
partition_key: str,
323-
row_key: str,
324-
**kwargs: Any
325-
) -> TableEntity:
326+
partition_key, # type: str
327+
row_key, # type: str
328+
**kwargs # type: Any
329+
):
330+
# type: (...) -> TableEntity
326331
"""Queries entities in a table.
327332
:param partition_key: The partition key of the entity.
328333
:type partition_key: str
@@ -338,25 +343,22 @@ async def get_entity(
338343
row_key=row_key,
339344
**kwargs)
340345
properties = _convert_to_entity(entity.additional_properties)
341-
return properties
346+
return properties
342347

343348
@distributed_trace_async
344-
async def upsert_entity(
349+
async def upsert_entity(
345350
self,
346-
entity: Dict[str,str],
347-
mode: UpdateMode=UpdateMode.MERGE,
348-
**kwargs: Any
349-
) -> None:
351+
entity, # type: Union[TableEntity, dict[str,str]]
352+
mode=UpdateMode.MERGE, # type: UpdateMode
353+
**kwargs # type: Any
354+
):
355+
# type: (...) -> None
350356

351357
"""Update/Merge or Insert entity into table.
352358
:param mode: Merge or Replace and Insert on fail
353359
:type mode: ~azure.data.tables.UpdateMode
354360
:param entity: The properties for the table entity.
355361
:type entity: dict[str, str]
356-
:param partition_key: The partition key of the entity.
357-
:type partition_key: str
358-
:param row_key: The row key of the entity.
359-
:type row_key: str
360362
:return: Entity mapping str to azure.data.tables.EntityProperty or None
361363
:rtype: None
362364
:raises: ~azure.core.exceptions.HttpResponseError
@@ -385,9 +387,9 @@ async def upsert_entity(
385387
else:
386388
raise ValueError('Mode type is not supported')
387389
except ResourceNotFoundError:
388-
await self.create_entity(
389-
partition_key=partition_key,
390-
row_key=row_key,
391-
table_entity_properties=entity,
392-
**kwargs
393-
)
390+
await self.create_entity(
391+
partition_key=partition_key,
392+
row_key=row_key,
393+
table_entity_properties=entity,
394+
**kwargs
395+
)

0 commit comments

Comments
 (0)