Skip to content

Commit 2dc212f

Browse files
author
Yalin Li
authored
[Tables] Fix mypy error from ETag and update docstring (#35236)
1 parent b919725 commit 2dc212f

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

sdk/tables/azure-data-tables/azure/data/tables/_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _reprocess_error(decoded_error, identifiers=None):
230230
):
231231
args_list = list(decoded_error.args)
232232
args_list[0] += (
233-
"\nA possible cause of this error could be that the account URL used to"
233+
"\nA possible cause of this error could be that the account URL used to "
234234
"create the Client includes an invalid path, for example the table name. Please check your account URL."
235235
)
236236
decoded_error.args = tuple(args_list)

sdk/tables/azure-data-tables/azure/data/tables/_table_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def delete(
246246
table=self.table_name,
247247
partition_key=self._encoder.prepare_key(partition_key), # type: ignore[arg-type]
248248
row_key=self._encoder.prepare_key(row_key), # type: ignore[arg-type]
249-
etag=etag, # type: ignore[arg-type] # Set None to skip checking etag.
249+
etag=etag or "*",
250250
match_condition=_get_match_condition(
251251
etag=etag, match_condition=match_condition or MatchConditions.Unconditionally
252252
),

sdk/tables/azure-data-tables/azure/data/tables/_table_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
9494

9595
@classmethod
9696
def from_connection_string(cls, conn_str: str, table_name: str, **kwargs: Any) -> "TableClient":
97-
"""Create TableClient from a Connection String.
97+
"""Creates TableClient from a Connection String.
9898
9999
:param str conn_str: A connection string to an Azure Tables account.
100100
:param str table_name: The table name.
@@ -400,7 +400,7 @@ def delete_entity(self, *args: Union[EntityType, str, T], **kwargs: Any) -> None
400400
table=self.table_name,
401401
partition_key=encoder.prepare_key(partition_key),
402402
row_key=encoder.prepare_key(row_key),
403-
etag=etag,
403+
etag=etag or "*",
404404
match_condition=match_condition,
405405
**kwargs,
406406
)
@@ -413,7 +413,7 @@ def delete_entity(self, *args: Union[EntityType, str, T], **kwargs: Any) -> None
413413
def create_entity(
414414
self, entity: EntityType, *, encoder: TableEntityEncoderABC[EntityType] = DEFAULT_ENCODER, **kwargs
415415
) -> Dict[str, Any]:
416-
"""Insert entity in a table.
416+
"""Inserts an entity in a table.
417417
418418
:param entity: The properties for the table entity.
419419
:type entity: Union[TableEntity, Mapping[str, Any]]
@@ -436,7 +436,7 @@ def create_entity(
436436

437437
@overload
438438
def create_entity(self, entity: T, *, encoder: TableEntityEncoderABC[T], **kwargs) -> Dict[str, Any]:
439-
"""Insert entity in a table.
439+
"""Inserts an entity in a table.
440440
441441
:param entity: The properties for the table entity.
442442
:type entity: Custom entity type
@@ -483,7 +483,7 @@ def update_entity(
483483
encoder: TableEntityEncoderABC[EntityType] = DEFAULT_ENCODER,
484484
**kwargs,
485485
) -> Dict[str, Any]:
486-
"""Updates an entity in a table.
486+
"""Updates an already existing entity in a table.
487487
488488
:param entity: The properties for the table entity.
489489
:type entity: ~azure.data.tables.TableEntity or dict[str, Any]
@@ -522,7 +522,7 @@ def update_entity(
522522
encoder: TableEntityEncoderABC[T],
523523
**kwargs,
524524
) -> Dict[str, Any]:
525-
"""Update entity in a table.
525+
"""Updates an already existing entity in a table.
526526
527527
:param entity: The properties for the table entity.
528528
:type entity: Custom entity type
@@ -745,7 +745,7 @@ def upsert_entity(
745745
encoder: TableEntityEncoderABC[EntityType] = DEFAULT_ENCODER,
746746
**kwargs,
747747
) -> Dict[str, Any]:
748-
"""Updates (merge or replace) an entity into a table.
748+
"""Updates (merge or replace) or inserts an entity into a table.
749749
750750
:param entity: The properties for the table entity.
751751
:type entity: ~azure.data.tables.TableEntity or dict[str, Any]
@@ -772,7 +772,7 @@ def upsert_entity(
772772
def upsert_entity(
773773
self, entity: T, mode: Union[str, UpdateMode] = UpdateMode.MERGE, *, encoder: TableEntityEncoderABC[T], **kwargs
774774
) -> Dict[str, Any]:
775-
"""Updates (merge or replace) an entity into a table.
775+
"""Updates (merge or replace) or inserts an entity into a table.
776776
777777
:param entity: The properties for the table entity.
778778
:type entity: Custom entity type

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
6969
api_version: Optional[str] = None,
7070
**kwargs: Any,
7171
) -> None:
72-
"""Create TableClient from a Credential.
72+
"""Creates TableClient from a Credential.
7373
7474
:param str endpoint: A URL to an Azure Tables account.
7575
:param str table_name: The table name.
@@ -356,6 +356,7 @@ async def delete_entity(
356356
) -> None:
357357
"""Deletes the specified entity in a table. No error will be raised if
358358
the entity or PartitionKey-RowKey pairing is not found.
359+
359360
:param entity: The entity to delete.
360361
:type entity: Custom entity type
361362
:keyword etag: Etag of the entity.
@@ -400,7 +401,7 @@ async def delete_entity(self, *args: Union[EntityType, str, T], **kwargs: Any) -
400401
table=self.table_name,
401402
partition_key=encoder.prepare_key(partition_key),
402403
row_key=encoder.prepare_key(row_key),
403-
etag=etag,
404+
etag=etag or "*",
404405
match_condition=match_condition,
405406
**kwargs,
406407
)
@@ -413,7 +414,7 @@ async def delete_entity(self, *args: Union[EntityType, str, T], **kwargs: Any) -
413414
async def create_entity(
414415
self, entity: EntityType, *, encoder: TableEntityEncoderABC[EntityType] = DEFAULT_ENCODER, **kwargs
415416
) -> Dict[str, Any]:
416-
"""Inserts entity in a table.
417+
"""Inserts an entity in a table.
417418
418419
:param entity: The properties for the table entity.
419420
:type entity: ~azure.data.tables.TableEntity or Mapping
@@ -437,7 +438,7 @@ async def create_entity(
437438

438439
@overload
439440
async def create_entity(self, entity: T, *, encoder: TableEntityEncoderABC[T], **kwargs) -> Dict[str, Any]:
440-
"""Insert entity in a table.
441+
"""Inserts an entity in a table.
441442
:param entity: The properties for the table entity.
442443
:type entity: Custom entity type
443444
:keyword encoder: The encoder used to serialize the outgoing Tables entities.
@@ -483,7 +484,7 @@ async def update_entity(
483484
encoder: TableEntityEncoderABC[EntityType] = DEFAULT_ENCODER,
484485
**kwargs,
485486
) -> Dict[str, Any]:
486-
"""Updates an entity in a table.
487+
"""Updates an already existing entity in a table.
487488
488489
:param entity: The properties for the table entity.
489490
:type entity: ~azure.data.tables.TableEntity or dict[str, Any]
@@ -522,7 +523,8 @@ async def update_entity(
522523
encoder: TableEntityEncoderABC[T],
523524
**kwargs,
524525
) -> Dict[str, Any]:
525-
"""Update entity in a table.
526+
"""Updates an already existing entity in a table.
527+
526528
:param entity: The properties for the table entity.
527529
:type entity: Custom entity type
528530
:param mode: Merge or Replace entity.
@@ -745,7 +747,7 @@ async def upsert_entity(
745747
encoder: TableEntityEncoderABC[EntityType] = DEFAULT_ENCODER,
746748
**kwargs,
747749
) -> Dict[str, Any]:
748-
"""Updates (merge or replace) an entity into a table.
750+
"""Updates (merge or replace) or inserts an entity into a table.
749751
750752
:param entity: The properties for the table entity.
751753
:type entity: ~azure.data.tables.TableEntity or dict[str, Any]
@@ -772,7 +774,8 @@ async def upsert_entity(
772774
async def upsert_entity(
773775
self, entity: T, mode: Union[str, UpdateMode] = UpdateMode.MERGE, *, encoder: TableEntityEncoderABC[T], **kwargs
774776
) -> Dict[str, Any]:
775-
"""Updates (merge or replace) an entity into a table.
777+
"""Updates (merge or replace) or inserts an entity into a table.
778+
776779
:param entity: The properties for the table entity.
777780
:type entity: Custom entity type
778781
:param mode: Merge or Replace entity.

sdk/tables/tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ extends:
2424
BLOB_STORAGE_ACCOUNT_KEY: $(python-storage-blob-storage-account-key)
2525
OAUTH_STORAGE_ACCOUNT_NAME: $(python-storage-oauth-storage-account-name)
2626
OAUTH_STORAGE_ACCOUNT_KEY: $(python-storage-oauth-storage-account-key)
27-
ACTIVE_DIRECTORY_APPLICATION_ID: $(aad-azure-sdk-test-client-id)
28-
ACTIVE_DIRECTORY_APPLICATION_SECRET: $(aad-azure-sdk-test-client-secret)
29-
ACTIVE_DIRECTORY_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
30-
CONNECTION_STRING: $(python-storage-blob-connection-string)
27+
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
28+
AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret)
29+
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
3130
BLOB_CONNECTION_STRING: $(python-storage-blob-connection-string)
3231
TEST_MODE: 'RunLiveNoRecord'
3332
AZURE_SKIP_LIVE_RECORDING: 'True'

0 commit comments

Comments
 (0)