Skip to content

Commit faca9aa

Browse files
Copilotbambriz
andcommitted
Apply comprehensive hardcoded strings fix to async versions: complete constants implementation across all Cosmos SDK files
Co-authored-by: bambriz <[email protected]>
1 parent a26042c commit faca9aa

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ async def create_item(
265265
:returns: A CosmosDict representing the new item. The dict will be empty if `no_response` is specified.
266266
:rtype: ~azure.cosmos.CosmosDict[str, Any]
267267
"""
268-
etag = kwargs.get('etag')
268+
etag = kwargs.get(Constants.Kwargs.ETAG)
269269
if etag is not None:
270270
warnings.warn(
271271
"The 'etag' flag does not apply to this method and is always ignored even if passed."
272272
" It will now be removed in the future.",
273273
DeprecationWarning)
274-
match_condition = kwargs.get('match_condition')
274+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
275275
if match_condition is not None:
276276
warnings.warn(
277277
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -1040,9 +1040,9 @@ async def upsert_item(
10401040
if priority is not None:
10411041
kwargs[Constants.Kwargs.PRIORITY] = priority
10421042
if etag is not None:
1043-
kwargs['etag'] = etag
1043+
kwargs[Constants.Kwargs.ETAG] = etag
10441044
if match_condition is not None:
1045-
kwargs['match_condition'] = match_condition
1045+
kwargs[Constants.Kwargs.MATCH_CONDITION] = match_condition
10461046
if no_response is not None:
10471047
kwargs[Constants.Kwargs.NO_RESPONSE] = no_response
10481048
if retry_write is not None:
@@ -1131,9 +1131,9 @@ async def replace_item(
11311131
if priority is not None:
11321132
kwargs[Constants.Kwargs.PRIORITY] = priority
11331133
if etag is not None:
1134-
kwargs['etag'] = etag
1134+
kwargs[Constants.Kwargs.ETAG] = etag
11351135
if match_condition is not None:
1136-
kwargs['match_condition'] = match_condition
1136+
kwargs[Constants.Kwargs.MATCH_CONDITION] = match_condition
11371137
if no_response is not None:
11381138
kwargs[Constants.Kwargs.NO_RESPONSE] = no_response
11391139
if retry_write is not None:
@@ -1220,9 +1220,9 @@ async def patch_item(
12201220
if priority is not None:
12211221
kwargs[Constants.Kwargs.PRIORITY] = priority
12221222
if etag is not None:
1223-
kwargs['etag'] = etag
1223+
kwargs[Constants.Kwargs.ETAG] = etag
12241224
if match_condition is not None:
1225-
kwargs['match_condition'] = match_condition
1225+
kwargs[Constants.Kwargs.MATCH_CONDITION] = match_condition
12261226
if no_response is not None:
12271227
kwargs[Constants.Kwargs.NO_RESPONSE] = no_response
12281228
if retry_write is not None:
@@ -1303,9 +1303,9 @@ async def delete_item(
13031303
if initial_headers is not None:
13041304
kwargs[Constants.Kwargs.INITIAL_HEADERS] = initial_headers
13051305
if etag is not None:
1306-
kwargs['etag'] = etag
1306+
kwargs[Constants.Kwargs.ETAG] = etag
13071307
if match_condition is not None:
1308-
kwargs['match_condition'] = match_condition
1308+
kwargs[Constants.Kwargs.MATCH_CONDITION] = match_condition
13091309
if priority is not None:
13101310
kwargs[Constants.Kwargs.PRIORITY] = priority
13111311
if retry_write is not None:
@@ -1559,13 +1559,13 @@ async def delete_all_items_by_partition_key(
15591559
:keyword int throughput_bucket: The desired throughput bucket for the client
15601560
:rtype: None
15611561
"""
1562-
etag = kwargs.get('etag')
1562+
etag = kwargs.get(Constants.Kwargs.ETAG)
15631563
if etag is not None:
15641564
warnings.warn(
15651565
"The 'etag' flag does not apply to this method and is always ignored even if passed."
15661566
" It will now be removed in the future.",
15671567
DeprecationWarning)
1568-
match_condition = kwargs.get('match_condition')
1568+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
15691569
if match_condition is not None:
15701570
warnings.warn(
15711571
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -1627,13 +1627,13 @@ async def execute_item_batch(
16271627
:raises ~azure.cosmos.exceptions.CosmosBatchOperationError: A transactional batch operation failed in the batch.
16281628
:rtype: ~azure.cosmos.CosmosList[Dict[str, Any]]
16291629
"""
1630-
etag = kwargs.get('etag')
1630+
etag = kwargs.get(Constants.Kwargs.ETAG)
16311631
if etag is not None:
16321632
warnings.warn(
16331633
"The 'etag' flag does not apply to this method and is always ignored even if passed."
16341634
" It will now be removed in the future.",
16351635
DeprecationWarning)
1636-
match_condition = kwargs.get('match_condition')
1636+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
16371637
if match_condition is not None:
16381638
warnings.warn(
16391639
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class CosmosClient: # pylint: disable=client-accepts-api-version-keyword
174174
Must be used along with a logger to work.
175175
:keyword ~logging.Logger logger: Logger to be used for collecting request diagnostics. Can be passed in at client
176176
level (to log all requests) or at a single request level. Requests will be logged at INFO level.
177-
:keyword bool no_response_on_write: Indicates whether service should be instructed to skip sending
177+
:keyword bool no_response_on_write: Indicates whether service should be instructed to skip sending
178178
response payloads for write operations on items by default unless specified differently per operation.
179179
:keyword int throughput_bucket: The desired throughput bucket for the client
180180
:keyword str user_agent_suffix: Allows user agent suffix to be specified when creating client
@@ -295,13 +295,13 @@ async def create_database(
295295
"The 'session_token' flag does not apply to this method and is always ignored even if passed."
296296
" It will now be removed in the future.",
297297
DeprecationWarning)
298-
etag = kwargs.get('etag')
298+
etag = kwargs.get(Constants.Kwargs.ETAG)
299299
if etag is not None:
300300
warnings.warn(
301301
"The 'etag' flag does not apply to this method and is always ignored even if passed."
302302
" It will now be removed in the future.",
303303
DeprecationWarning)
304-
match_condition = kwargs.get('match_condition')
304+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
305305
if match_condition is not None:
306306
warnings.warn(
307307
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -353,13 +353,13 @@ async def create_database_if_not_exists( # pylint: disable=redefined-builtin
353353
"The 'session_token' flag does not apply to this method and is always ignored even if passed."
354354
" It will now be removed in the future.",
355355
DeprecationWarning)
356-
etag = kwargs.get('etag')
356+
etag = kwargs.get(Constants.Kwargs.ETAG)
357357
if etag is not None:
358358
warnings.warn(
359359
"The 'etag' flag does not apply to this method and is always ignored even if passed."
360360
" It will now be removed in the future.",
361361
DeprecationWarning)
362-
match_condition = kwargs.get('match_condition')
362+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
363363
if match_condition is not None:
364364
warnings.warn(
365365
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -430,7 +430,7 @@ def list_databases(
430430
kwargs[Constants.Kwargs.THROUGHPUT_BUCKET] = throughput_bucket
431431
feed_options = _build_options(kwargs)
432432
if max_item_count is not None:
433-
feed_options["maxItemCount"] = max_item_count
433+
feed_options[Constants.InternalOptions.MAX_ITEM_COUNT] = max_item_count
434434

435435
result = self.client_connection.ReadDatabases(options=feed_options, **kwargs)
436436
if response_hook:
@@ -476,7 +476,7 @@ def query_databases(
476476
kwargs[Constants.Kwargs.THROUGHPUT_BUCKET] = throughput_bucket
477477
feed_options = _build_options(kwargs)
478478
if max_item_count is not None:
479-
feed_options["maxItemCount"] = max_item_count
479+
feed_options[Constants.InternalOptions.MAX_ITEM_COUNT] = max_item_count
480480

481481
result = self.client_connection.QueryDatabases(
482482
query=query if parameters is None else {"query": query, "parameters": parameters},
@@ -514,13 +514,13 @@ async def delete_database(
514514
"The 'session_token' flag does not apply to this method and is always ignored even if passed."
515515
" It will now be removed in the future.",
516516
DeprecationWarning)
517-
etag = kwargs.get('etag')
517+
etag = kwargs.get(Constants.Kwargs.ETAG)
518518
if etag is not None:
519519
warnings.warn(
520520
"The 'etag' flag does not apply to this method and is always ignored even if passed."
521521
" It will now be removed in the future.",
522522
DeprecationWarning)
523-
match_condition = kwargs.get('match_condition')
523+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
524524
if match_condition is not None:
525525
warnings.warn(
526526
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ async def create_container(
249249
"The 'session_token' flag does not apply to this method and is always ignored even if passed."
250250
" It will now be removed in the future.",
251251
DeprecationWarning)
252-
etag = kwargs.get('etag')
252+
etag = kwargs.get(Constants.Kwargs.ETAG)
253253
if etag is not None:
254254
warnings.warn(
255255
"The 'etag' flag does not apply to this method and is always ignored even if passed."
256256
" It will now be removed in the future.",
257257
DeprecationWarning)
258-
match_condition = kwargs.get('match_condition')
258+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
259259
if match_condition is not None:
260260
warnings.warn(
261261
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -368,13 +368,13 @@ async def create_container_if_not_exists(
368368
"The 'session_token' flag does not apply to this method and is always ignored even if passed."
369369
" It will now be removed in the future.",
370370
DeprecationWarning)
371-
etag = kwargs.get('etag')
371+
etag = kwargs.get(Constants.Kwargs.ETAG)
372372
if etag is not None:
373373
warnings.warn(
374374
"The 'etag' flag does not apply to this method and is always ignored even if passed."
375375
" It will now be removed in the future.",
376376
DeprecationWarning)
377-
match_condition = kwargs.get('match_condition')
377+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
378378
if match_condition is not None:
379379
warnings.warn(
380380
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -474,7 +474,7 @@ def list_containers(
474474
kwargs[Constants.Kwargs.INITIAL_HEADERS] = initial_headers
475475
feed_options = _build_options(kwargs)
476476
if max_item_count is not None:
477-
feed_options["maxItemCount"] = max_item_count
477+
feed_options[Constants.InternalOptions.MAX_ITEM_COUNT] = max_item_count
478478

479479
result = self.client_connection.ReadContainers(
480480
database_link=self.database_link, options=feed_options, **kwargs
@@ -519,7 +519,7 @@ def query_containers(
519519
kwargs[Constants.Kwargs.INITIAL_HEADERS] = initial_headers
520520
feed_options = _build_options(kwargs)
521521
if max_item_count is not None:
522-
feed_options["maxItemCount"] = max_item_count
522+
feed_options[Constants.InternalOptions.MAX_ITEM_COUNT] = max_item_count
523523

524524
result = self.client_connection.QueryContainers(
525525
database_link=self.database_link,
@@ -593,13 +593,13 @@ async def replace_container(
593593
"The 'session_token' flag does not apply to this method and is always ignored even if passed."
594594
" It will now be removed in the future.",
595595
DeprecationWarning)
596-
etag = kwargs.get('etag')
596+
etag = kwargs.get(Constants.Kwargs.ETAG)
597597
if etag is not None:
598598
warnings.warn(
599599
"The 'etag' flag does not apply to this method and is always ignored even if passed."
600600
" It will now be removed in the future.",
601601
DeprecationWarning)
602-
match_condition = kwargs.get('match_condition')
602+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
603603
if match_condition is not None:
604604
warnings.warn(
605605
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -662,13 +662,13 @@ async def delete_container(
662662
"The 'session_token' flag does not apply to this method and is always ignored even if passed."
663663
" It will now be removed in the future.",
664664
DeprecationWarning)
665-
etag = kwargs.get('etag')
665+
etag = kwargs.get(Constants.Kwargs.ETAG)
666666
if etag is not None:
667667
warnings.warn(
668668
"The 'etag' flag does not apply to this method and is always ignored even if passed."
669669
" It will now be removed in the future.",
670670
DeprecationWarning)
671-
match_condition = kwargs.get('match_condition')
671+
match_condition = kwargs.get(Constants.Kwargs.MATCH_CONDITION)
672672
if match_condition is not None:
673673
warnings.warn(
674674
"The 'match_condition' flag does not apply to this method and is always ignored even if passed."
@@ -768,7 +768,7 @@ def list_users(
768768
"""
769769
feed_options = _build_options(kwargs)
770770
if max_item_count is not None:
771-
feed_options["maxItemCount"] = max_item_count
771+
feed_options[Constants.InternalOptions.MAX_ITEM_COUNT] = max_item_count
772772

773773
result = self.client_connection.ReadUsers(
774774
database_link=self.database_link, options=feed_options, **kwargs
@@ -804,7 +804,7 @@ def query_users(
804804
"""
805805
feed_options = _build_options(kwargs)
806806
if max_item_count is not None:
807-
feed_options["maxItemCount"] = max_item_count
807+
feed_options[Constants.InternalOptions.MAX_ITEM_COUNT] = max_item_count
808808

809809
result = self.client_connection.QueryUsers(
810810
database_link=self.database_link,

0 commit comments

Comments
 (0)