Skip to content

Commit 9e9d5eb

Browse files
author
Yalin Li
authored
[Tables] Fix pylint and sphinx errors (#35081)
1 parent ffd903f commit 9e9d5eb

14 files changed

+280
-258
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def metadata(self) -> EntityMetadata:
5353

5454
class EdmType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
5555
"""
56-
Used by :class:`~.EntityProperty` to represent the type of the entity property
57-
to be stored by the Table service.
56+
Represent the type of the entity property to be stored by the Table service.
5857
"""
5958

6059
BINARY = "Edm.Binary"
@@ -83,18 +82,20 @@ class EdmType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
8382

8483

8584
EntityProperty = NamedTuple("EntityProperty", [("value", Any), ("edm_type", Union[str, EdmType])])
86-
"""
87-
An entity property. Used to explicitly set :class:`~EdmType` when necessary.
85+
"""An entity property. Used to explicitly set :class:`~azure.data.Tables.EdmType` when necessary.
8886
8987
Values which require explicit typing are GUID, INT64, and BINARY. Other EdmTypes
9088
may be explicitly create as EntityProperty objects but need not be. For example,
91-
the below with both create STRING typed properties on the entity::
89+
the below with both create STRING typed properties on the entity:
90+
91+
.. code-block:: python
92+
9293
entity = TableEntity()
9394
entity.a = 'b'
9495
entity.x = EntityProperty('y', EdmType.STRING)
9596
96-
:param value:
97+
:param value: The entity property value.
9798
:type value: Any
98-
:param edm_type: Type of the value
99+
:param edm_type: The Edm type of the entity property value.
99100
:type edm_type: str or ~azure.data.tables.EdmType
100101
"""

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,11 @@ def service_properties_deserialize(generated: GenTableServiceProperties) -> Dict
471471
),
472472
"hour_metrics": TableMetrics._from_generated(generated.hour_metrics), # pylint: disable=protected-access
473473
"minute_metrics": TableMetrics._from_generated(generated.minute_metrics), # pylint: disable=protected-access
474-
"cors": [TableCorsRule._from_generated(cors) for cors in generated.cors] # pylint: disable=protected-access
475-
if generated.cors
476-
else generated.cors,
474+
"cors": (
475+
[TableCorsRule._from_generated(cors) for cors in generated.cors] # pylint: disable=protected-access
476+
if generated.cors
477+
else generated.cors
478+
),
477479
}
478480

479481

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

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,25 @@ def create(self, entity: EntityType, **kwargs) -> None:
123123
request.url = self._base_url + request.url
124124
self.requests.append(request)
125125

126-
def update(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.MERGE, **kwargs) -> None:
126+
def update(
127+
self,
128+
entity: EntityType,
129+
mode: Union[str, UpdateMode] = UpdateMode.MERGE,
130+
*,
131+
etag: Optional[str] = None,
132+
match_condition: Optional[MatchConditions] = None,
133+
**kwargs,
134+
) -> None:
127135
"""Adds an update operation to the current batch.
128136
129137
:param entity: The properties for the table entity.
130138
:type entity: ~azure.data.tables.TableEntity or dict[str, Any]
131139
:param mode: Merge or Replace entity
132140
:type mode: ~azure.data.tables.UpdateMode
133-
:keyword str etag: Etag of the entity
134-
:keyword match_condition: MatchCondition
135-
:paramtype match_condition: ~azure.core.MatchCondition
141+
:keyword etag: Etag of the entity.
142+
:paramtype etag: str or None
143+
:keyword match_condition: The match condition to use upon the etag.
144+
:paramtype match_condition: ~azure.core.MatchConditions or None
136145
:return: None
137146
:raises ValueError:
138147
@@ -150,8 +159,6 @@ def update(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.M
150159
partition_key = _prepare_key(entity["PartitionKey"])
151160
row_key = _prepare_key(entity["RowKey"])
152161

153-
match_condition = kwargs.pop("match_condition", None)
154-
etag = kwargs.pop("etag", None)
155162
if match_condition and not etag and isinstance(entity, TableEntity):
156163
if hasattr(entity, "metadata"):
157164
etag = entity.metadata.get("etag")
@@ -188,14 +195,22 @@ def update(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.M
188195
request.url = self._base_url + request.url
189196
self.requests.append(request)
190197

191-
def delete(self, entity: EntityType, **kwargs) -> None:
198+
def delete(
199+
self,
200+
entity: EntityType,
201+
*,
202+
etag: Optional[str] = None,
203+
match_condition: Optional[MatchConditions] = None,
204+
**kwargs,
205+
) -> None:
192206
"""Adds a delete operation to the current branch.
193207
194-
param entity: The properties for the table entity.
208+
:param entity: The properties for the table entity.
195209
:type entity: ~azure.data.tables.TableEntity or dict[str, Any]
196-
:keyword str etag: Etag of the entity
197-
:keyword match_condition: MatchCondition
198-
:paramtype match_condition: ~azure.core.MatchCondition
210+
:keyword etag: Etag of the entity.
211+
:paramtype etag: str or None
212+
:keyword match_condition: The match condition to use upon the etag.
213+
:paramtype match_condition: ~azure.core.MatchConditions or None
199214
:return: None
200215
:raises: ValueError
201216
@@ -209,27 +224,24 @@ def delete(self, entity: EntityType, **kwargs) -> None:
209224
:caption: Creating and adding an entity to a Table
210225
"""
211226
self._verify_partition_key(entity)
212-
match_condition = kwargs.pop("match_condition", None)
213-
etag = kwargs.pop("etag", None)
214227
if match_condition and not etag and isinstance(entity, TableEntity):
215228
etag = entity.metadata.get("etag")
216-
match_condition = _get_match_condition(
217-
etag=etag, match_condition=match_condition or MatchConditions.Unconditionally
218-
)
219229
request = build_table_delete_entity_request(
220230
table=self.table_name,
221231
partition_key=_prepare_key(entity["PartitionKey"]),
222232
row_key=_prepare_key(entity["RowKey"]),
223-
etag=etag,
224-
match_condition=match_condition,
233+
etag=etag, # type: ignore[arg-type] # Set None to skip checking etag.
234+
match_condition=_get_match_condition(
235+
etag=etag, match_condition=match_condition or MatchConditions.Unconditionally
236+
),
225237
version=self._config.version,
226238
**kwargs,
227239
)
228240
request.url = self._base_url + request.url
229241
self.requests.append(request)
230242

231243
def upsert(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.MERGE, **kwargs) -> None:
232-
"""Adds an upsert (update/merge) operation to the batch.
244+
"""Adds an upsert (merge or replace) operation to the batch.
233245
234246
:param entity: The properties for the table entity.
235247
:type entity: ~azure.data.tables.TableEntity or dict[str, Any]

0 commit comments

Comments
 (0)