Skip to content

Commit d4445ad

Browse files
authored
typing fixes. (#34208)
* typing fixes. * update
1 parent 3f4b1c9 commit d4445ad

File tree

9 files changed

+145
-61
lines changed

9 files changed

+145
-61
lines changed

sdk/search/azure-search-documents/azure/search/documents/_search_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ def search(
292292
:keyword vector_filter_mode: Determines whether or not filters are applied before or after the
293293
vector search is performed. Default is 'preFilter'. Known values are: "postFilter" and "preFilter".
294294
:paramtype vector_filter_mode: str or VectorFilterMode
295+
:return: List of search results.
295296
:rtype: SearchItemPaged[dict]
296297
297298
.. admonition:: Example:
@@ -429,7 +430,7 @@ def suggest(
429430
:keyword int top: The number of suggestions to retrieve. The value must be a number between 1 and
430431
100. The default is 5.
431432
432-
:return: List of documents.
433+
:return: List of suggestion results.
433434
:rtype: list[dict]
434435
435436
.. admonition:: Example:
@@ -474,6 +475,7 @@ def autocomplete(
474475
suggester_name: str,
475476
*,
476477
mode: Optional[Union[str, AutocompleteMode]] = None,
478+
filter: Optional[str] = None,
477479
use_fuzzy_matching: Optional[bool] = None,
478480
highlight_post_tag: Optional[str] = None,
479481
highlight_pre_tag: Optional[str] = None,
@@ -510,6 +512,7 @@ def autocomplete(
510512
terms. Target fields must be included in the specified suggester.
511513
:keyword int top: The number of auto-completed terms to retrieve. This must be a value between 1 and
512514
100. The default is 5.
515+
:return: List of auto-completion results.
513516
:rtype: list[dict]
514517
515518
.. admonition:: Example:
@@ -522,7 +525,7 @@ def autocomplete(
522525
:caption: Get a auto-completions.
523526
"""
524527
autocomplete_mode = mode
525-
filter_arg = kwargs.pop("filter", None)
528+
filter_arg = filter
526529
search_fields_str = ",".join(search_fields) if search_fields else None
527530
query = AutocompleteQuery(
528531
search_text=search_text,

sdk/search/azure-search-documents/azure/search/documents/aio/_search_client_async.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ async def search(
296296
vector search is performed. Default is 'preFilter'. Known values are: "postFilter" and "preFilter".
297297
:paramtype vector_filter_mode: str or VectorFilterMode
298298
:return: A list of documents (dicts) matching the specified search criteria.
299+
:return: List of search results.
299300
:rtype: AsyncSearchItemPaged[dict]
300301
301302
.. admonition:: Example:
@@ -427,7 +428,7 @@ async def suggest(
427428
included in the results.
428429
:keyword int top: The number of suggestions to retrieve. The value must be a number between 1 and
429430
100. The default is 5.
430-
:return: List of documents.
431+
:return: List of suggestion results.
431432
:rtype: list[dict]
432433
433434
.. admonition:: Example:
@@ -472,6 +473,7 @@ async def autocomplete(
472473
suggester_name: str,
473474
*,
474475
mode: Optional[Union[str, AutocompleteMode]] = None,
476+
filter: Optional[str] = None,
475477
use_fuzzy_matching: Optional[bool] = None,
476478
highlight_post_tag: Optional[str] = None,
477479
highlight_pre_tag: Optional[str] = None,
@@ -508,6 +510,7 @@ async def autocomplete(
508510
terms. Target fields must be included in the specified suggester.
509511
:keyword int top: The number of auto-completed terms to retrieve. This must be a value between 1 and
510512
100. The default is 5.
513+
:return: List of auto-completion results.
511514
:rtype: list[Dict]
512515
513516
.. admonition:: Example:
@@ -520,7 +523,7 @@ async def autocomplete(
520523
:caption: Get a auto-completions.
521524
"""
522525
autocomplete_mode = mode
523-
filter_arg = kwargs.pop("filter", None)
526+
filter_arg = filter
524527
search_fields_str = ",".join(search_fields) if search_fields else None
525528
query = AutocompleteQuery(
526529
search_text=search_text,

sdk/search/azure-search-documents/azure/search/documents/indexes/_search_index_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ def delete_synonym_map(
385385
the SynonymMap model must be provided instead of the name. It is enough to provide
386386
the name of the synonym map to delete unconditionally.
387387
388-
:param name: The synonym map name or object to delete
389-
:type name: str or ~azure.search.documents.indexes.models.SynonymMap
388+
:param synonym_map: The synonym map name or object to delete
389+
:type synonym_map: str or ~azure.search.documents.indexes.models.SynonymMap
390390
:keyword match_condition: The match condition to use upon the etag
391391
:paramtype match_condition: ~azure.core.MatchConditions
392392

sdk/search/azure-search-documents/azure/search/documents/indexes/_search_indexer_client.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ def create_or_update_indexer(
111111
indexer: SearchIndexer,
112112
*,
113113
match_condition: MatchConditions = MatchConditions.Unconditionally,
114+
skip_indexer_reset_requirement_for_cache: Optional[bool] = None,
115+
disable_cache_reprocessing_change_detection: Optional[bool] = None,
114116
**kwargs: Any
115117
) -> SearchIndexer:
116118
"""Creates a new indexer or updates an indexer if it already exists.
@@ -132,7 +134,13 @@ def create_or_update_indexer(
132134
kwargs.update(access_condition)
133135
name = indexer.name
134136
result = self._client.indexers.create_or_update(
135-
indexer_name=name, indexer=indexer, prefer="return=representation", error_map=error_map, **kwargs
137+
indexer_name=name,
138+
indexer=indexer,
139+
prefer="return=representation",
140+
error_map=error_map,
141+
skip_indexer_reset_requirement_for_cache=skip_indexer_reset_requirement_for_cache,
142+
disable_cache_reprocessing_change_detection=disable_cache_reprocessing_change_detection,
143+
**kwargs
136144
)
137145
return result
138146

@@ -281,7 +289,12 @@ def reset_indexer(self, name: str, **kwargs: Any) -> None:
281289

282290
@distributed_trace
283291
def reset_documents(
284-
self, indexer: Union[str, SearchIndexer], keys_or_ids: DocumentKeysOrIds, **kwargs: Any
292+
self,
293+
indexer: Union[str, SearchIndexer],
294+
keys_or_ids: DocumentKeysOrIds,
295+
*,
296+
overwrite: bool = False,
297+
**kwargs: Any
285298
) -> None:
286299
"""Resets specific documents in the datasource to be selectively re-ingested by the indexer.
287300
@@ -302,7 +315,7 @@ def reset_documents(
302315
name = indexer.name # type: ignore
303316
except AttributeError:
304317
name = indexer
305-
return self._client.indexers.reset_docs(name, **kwargs)
318+
return self._client.indexers.reset_docs(name, overwrite=overwrite, **kwargs)
306319

307320
@distributed_trace
308321
def get_indexer_status(self, name: str, **kwargs: Any) -> SearchIndexerStatus:
@@ -358,6 +371,7 @@ def create_or_update_data_source_connection(
358371
data_source_connection: SearchIndexerDataSourceConnection,
359372
*,
360373
match_condition: MatchConditions = MatchConditions.Unconditionally,
374+
skip_indexer_reset_requirement_for_cache: Optional[bool] = None,
361375
**kwargs: Any
362376
) -> SearchIndexerDataSourceConnection:
363377
"""Creates a new data source connection or updates a data source connection if it already exists.
@@ -381,6 +395,7 @@ def create_or_update_data_source_connection(
381395
data_source=packed_data_source,
382396
prefer="return=representation",
383397
error_map=error_map,
398+
skip_indexer_reset_requirement_for_cache=skip_indexer_reset_requirement_for_cache,
384399
**kwargs
385400
)
386401
# pylint:disable=protected-access
@@ -584,6 +599,8 @@ def create_or_update_skillset(
584599
skillset: SearchIndexerSkillset,
585600
*,
586601
match_condition: MatchConditions = MatchConditions.Unconditionally,
602+
skip_indexer_reset_requirement_for_cache: Optional[bool] = None,
603+
disable_cache_reprocessing_change_detection: Optional[bool] = None,
587604
**kwargs: Any
588605
) -> SearchIndexerSkillset:
589606
# pylint:disable=protected-access
@@ -614,6 +631,8 @@ def create_or_update_skillset(
614631
skillset=skillset_gen,
615632
prefer="return=representation",
616633
error_map=error_map,
634+
skip_indexer_reset_requirement_for_cache=skip_indexer_reset_requirement_for_cache,
635+
disable_cache_reprocessing_change_detection=disable_cache_reprocessing_change_detection,
617636
**kwargs
618637
)
619638
return SearchIndexerSkillset._from_generated(result) # pylint:disable=protected-access

sdk/search/azure-search-documents/azure/search/documents/indexes/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_access_conditions(
6464
error_map[412] = ResourceNotFoundError
6565
if match_condition == MatchConditions.IfMissing:
6666
error_map[412] = ResourceExistsError
67-
return error_map, dict(if_match=if_match, if_none_match=if_none_match)
67+
return error_map, {"if_match": if_match, "if_none_match": if_none_match}
6868
except AttributeError as ex:
6969
raise ValueError("Unable to get e_tag from the model") from ex
7070

sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_search_index_client.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ async def get_index_statistics(self, index_name: str, **kwargs: Any) -> MutableM
163163
return result.as_dict()
164164

165165
@distributed_trace_async
166-
async def delete_index(self, index: Union[str, SearchIndex], **kwargs: Any) -> None:
166+
async def delete_index(
167+
self,
168+
index: Union[str, SearchIndex],
169+
*,
170+
match_condition: MatchConditions = MatchConditions.Unconditionally,
171+
**kwargs: Any
172+
) -> None:
167173
"""Deletes a search index and all the documents it contains. The model must be
168174
provided instead of the name to use the access conditions
169175
@@ -183,9 +189,7 @@ async def delete_index(self, index: Union[str, SearchIndex], **kwargs: Any) -> N
183189
:caption: Delete an index.
184190
"""
185191
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
186-
error_map, access_condition = get_access_conditions(
187-
index, kwargs.pop("match_condition", MatchConditions.Unconditionally)
188-
)
192+
error_map, access_condition = get_access_conditions(index, match_condition)
189193
kwargs.update(access_condition)
190194
try:
191195
index_name = index.name # type: ignore
@@ -378,8 +382,8 @@ async def delete_synonym_map(
378382
the SynonymMap model must be provided instead of the name. It is enough to provide
379383
the name of the synonym map to delete unconditionally.
380384
381-
:param name: The synonym map name or object to delete
382-
:type name: str or ~azure.search.documents.indexes.models.SynonymMap
385+
:param synonym_map: The synonym map name or object to delete
386+
:type synonym_map: str or ~azure.search.documents.indexes.models.SynonymMap
383387
:keyword match_condition: The match condition to use upon the etag
384388
:paramtype match_condition: ~azure.core.MatchConditions
385389

sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_search_indexer_client.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@ async def create_or_update_indexer(
107107
indexer: SearchIndexer,
108108
*,
109109
match_condition: MatchConditions = MatchConditions.Unconditionally,
110+
skip_indexer_reset_requirement_for_cache: Optional[bool] = None,
111+
disable_cache_reprocessing_change_detection: Optional[bool] = None,
110112
**kwargs: Any
111113
) -> SearchIndexer:
112114
"""Creates a new indexer or updates a indexer if it already exists.
113115
114116
:param indexer: The definition of the indexer to create or update.
115117
:type indexer: ~azure.search.documents.indexes.models.SearchIndexer
118+
:keyword match_condition: The match condition to use upon the etag
119+
:paramtype match_condition: ~azure.core.MatchConditions
116120
:keyword skip_indexer_reset_requirement_for_cache: Ignores cache reset requirements.
117121
:paramtype skip_indexer_reset_requirement_for_cache: bool
118122
:keyword disable_cache_reprocessing_change_detection: Disables cache reprocessing change
@@ -126,7 +130,13 @@ async def create_or_update_indexer(
126130
kwargs.update(access_condition)
127131
name = indexer.name
128132
result = await self._client.indexers.create_or_update(
129-
indexer_name=name, indexer=indexer, prefer="return=representation", error_map=error_map, **kwargs
133+
indexer_name=name,
134+
indexer=indexer,
135+
prefer="return=representation",
136+
error_map=error_map,
137+
skip_indexer_reset_requirement_for_cache=skip_indexer_reset_requirement_for_cache,
138+
disable_cache_reprocessing_change_detection=disable_cache_reprocessing_change_detection,
139+
**kwargs
130140
)
131141
return result
132142

@@ -203,8 +213,8 @@ async def delete_indexer(
203213
must be provided instead of the name. It is enough to provide
204214
the name of the indexer to delete unconditionally.
205215
206-
:param name: The name or the indexer object to delete.
207-
:type name: str or ~azure.search.documents.indexes.models.SearchIndexer
216+
:param indexer: The name or the indexer object to delete.
217+
:type indexer: str or ~azure.search.documents.indexes.models.SearchIndexer
208218
:keyword match_condition: The match condition to use upon the etag
209219
:paramtype match_condition: ~azure.core.MatchConditions
210220
@@ -266,7 +276,12 @@ async def reset_indexer(self, name: str, **kwargs: Any) -> None:
266276

267277
@distributed_trace_async
268278
async def reset_documents(
269-
self, indexer: Union[str, SearchIndexer], keys_or_ids: DocumentKeysOrIds, **kwargs: Any
279+
self,
280+
indexer: Union[str, SearchIndexer],
281+
keys_or_ids: DocumentKeysOrIds,
282+
*,
283+
overwrite: bool = False,
284+
**kwargs: Any
270285
) -> None:
271286
"""Resets specific documents in the datasource to be selectively re-ingested by the indexer.
272287
@@ -287,7 +302,7 @@ async def reset_documents(
287302
name = indexer.name # type: ignore
288303
except AttributeError:
289304
name = indexer
290-
await self._client.indexers.reset_docs(name, **kwargs)
305+
await self._client.indexers.reset_docs(name, overwrite=overwrite, **kwargs)
291306
return
292307

293308
@distributed_trace_async
@@ -343,6 +358,7 @@ async def create_or_update_data_source_connection(
343358
data_source_connection: SearchIndexerDataSourceConnection,
344359
*,
345360
match_condition: MatchConditions = MatchConditions.Unconditionally,
361+
skip_indexer_reset_requirement_for_cache: Optional[bool] = None,
346362
**kwargs: Any
347363
) -> SearchIndexerDataSourceConnection:
348364
"""Creates a new data source connection or updates a data source connection if it already exists.
@@ -369,6 +385,7 @@ async def create_or_update_data_source_connection(
369385
data_source=packed_data_source,
370386
prefer="return=representation",
371387
error_map=error_map,
388+
skip_indexer_reset_requirement_for_cache=skip_indexer_reset_requirement_for_cache,
372389
**kwargs
373390
)
374391
return SearchIndexerDataSourceConnection._from_generated(result)
@@ -570,6 +587,8 @@ async def create_or_update_skillset(
570587
skillset: SearchIndexerSkillset,
571588
*,
572589
match_condition: MatchConditions = MatchConditions.Unconditionally,
590+
skip_indexer_reset_requirement_for_cache: Optional[bool] = None,
591+
disable_cache_reprocessing_change_detection: Optional[bool] = None,
573592
**kwargs: Any
574593
) -> SearchIndexerSkillset:
575594
# pylint:disable=protected-access
@@ -599,6 +618,8 @@ async def create_or_update_skillset(
599618
skillset=skillset_gen,
600619
prefer="return=representation",
601620
error_map=error_map,
621+
skip_indexer_reset_requirement_for_cache=skip_indexer_reset_requirement_for_cache,
622+
disable_cache_reprocessing_change_detection=disable_cache_reprocessing_change_detection,
602623
**kwargs
603624
)
604625
return SearchIndexerSkillset._from_generated(result) # pylint:disable=protected-access

0 commit comments

Comments
 (0)