Skip to content

Commit 6454f84

Browse files
committed
black
1 parent a092c05 commit 6454f84

1 file changed

Lines changed: 17 additions & 57 deletions

File tree

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

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ class SearchClient(HeadersMixin):
6666
_client: SearchIndexClient
6767

6868
def __init__(
69-
self,
70-
endpoint: str,
71-
index_name: str,
72-
credential: Union[AzureKeyCredential, AsyncTokenCredential],
73-
**kwargs: Any
69+
self, endpoint: str, index_name: str, credential: Union[AzureKeyCredential, AsyncTokenCredential], **kwargs: Any
7470
) -> None:
7571
self._api_version = kwargs.pop("api_version", DEFAULT_VERSION)
7672
self._index_documents_batch = IndexDocumentsBatch()
@@ -89,9 +85,7 @@ def __init__(
8985
)
9086
else:
9187
self._aad = True
92-
authentication_policy = get_authentication_policy(
93-
credential, audience=audience, is_async=True
94-
)
88+
authentication_policy = get_authentication_policy(credential, audience=audience, is_async=True)
9589
self._client = SearchIndexClient(
9690
endpoint=endpoint,
9791
index_name=index_name,
@@ -102,9 +96,7 @@ def __init__(
10296
)
10397

10498
def __repr__(self) -> str:
105-
return "<SearchClient [endpoint={}, index={}]>".format(
106-
repr(self._endpoint), repr(self._index_name)
107-
)[:1024]
99+
return "<SearchClient [endpoint={}, index={}]>".format(repr(self._endpoint), repr(self._index_name))[:1024]
108100

109101
async def close(self) -> None:
110102
"""Close the :class:`~azure.search.documents.aio.SearchClient` session.
@@ -125,9 +117,7 @@ async def get_document_count(self, **kwargs: Any) -> int:
125117
return int(await self._client.documents.count(**kwargs))
126118

127119
@distributed_trace_async
128-
async def get_document(
129-
self, key: str, selected_fields: Optional[List[str]] = None, **kwargs: Any
130-
) -> Dict:
120+
async def get_document(self, key: str, selected_fields: Optional[List[str]] = None, **kwargs: Any) -> Dict:
131121
"""Retrieve a document from the Azure search index by its key.
132122
133123
:param key: The primary key value for the document to retrieve
@@ -147,9 +137,7 @@ async def get_document(
147137
:caption: Get a specific document from the search index.
148138
"""
149139
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
150-
result = await self._client.documents.get(
151-
key=key, selected_fields=selected_fields, **kwargs
152-
)
140+
result = await self._client.documents.get(key=key, selected_fields=selected_fields, **kwargs)
153141
return cast(dict, result)
154142

155143
@distributed_trace_async
@@ -340,16 +328,8 @@ async def search(
340328
include_total_result_count = include_total_count
341329
filter_arg = filter
342330
search_fields_str = ",".join(search_fields) if search_fields else None
343-
answers = (
344-
query_answer
345-
if not query_answer_count
346-
else "{}|count-{}".format(query_answer, query_answer_count)
347-
)
348-
answers = (
349-
answers
350-
if not query_answer_threshold
351-
else "{}|threshold-{}".format(answers, query_answer_threshold)
352-
)
331+
answers = query_answer if not query_answer_count else "{}|count-{}".format(query_answer, query_answer_count)
332+
answers = answers if not query_answer_threshold else "{}|threshold-{}".format(answers, query_answer_threshold)
353333
captions = (
354334
query_caption
355335
if not query_caption_highlight
@@ -396,9 +376,7 @@ async def search(
396376
query.order_by(order_by)
397377
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
398378
kwargs["api_version"] = self._api_version
399-
return AsyncSearchItemPaged(
400-
self._client, query, kwargs, page_iterator_class=AsyncSearchPageIterator
401-
)
379+
return AsyncSearchItemPaged(self._client, query, kwargs, page_iterator_class=AsyncSearchPageIterator)
402380

403381
@distributed_trace_async
404382
async def suggest(
@@ -481,9 +459,7 @@ async def suggest(
481459
query.order_by(order_by)
482460
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
483461
request = cast(SuggestRequest, query.request)
484-
response = await self._client.documents.suggest_post(
485-
suggest_request=request, **kwargs
486-
)
462+
response = await self._client.documents.suggest_post(suggest_request=request, **kwargs)
487463
assert response.results is not None # Hint for mypy
488464
results = [r.as_dict() for r in response.results]
489465
return results
@@ -560,17 +536,13 @@ async def autocomplete(
560536

561537
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
562538
request = cast(AutocompleteRequest, query.request)
563-
response = await self._client.documents.autocomplete_post(
564-
autocomplete_request=request, **kwargs
565-
)
539+
response = await self._client.documents.autocomplete_post(autocomplete_request=request, **kwargs)
566540
assert response.results is not None # Hint for mypy
567541
results = [r.as_dict() for r in response.results]
568542
return results
569543

570544
# pylint:disable=client-method-missing-tracing-decorator-async
571-
async def upload_documents(
572-
self, documents: List[Dict], **kwargs: Any
573-
) -> List[IndexingResult]:
545+
async def upload_documents(self, documents: List[Dict], **kwargs: Any) -> List[IndexingResult]:
574546
"""Upload documents to the Azure search index.
575547
576548
An upload action is similar to an "upsert" where the document will be
@@ -599,9 +571,7 @@ async def upload_documents(
599571
return cast(List[IndexingResult], results)
600572

601573
# pylint:disable=client-method-missing-tracing-decorator-async, delete-operation-wrong-return-type
602-
async def delete_documents(
603-
self, documents: List[Dict], **kwargs: Any
604-
) -> List[IndexingResult]:
574+
async def delete_documents(self, documents: List[Dict], **kwargs: Any) -> List[IndexingResult]:
605575
"""Delete documents from the Azure search index
606576
607577
Delete removes the specified document from the index. Any field you
@@ -635,9 +605,7 @@ async def delete_documents(
635605
return cast(List[IndexingResult], results)
636606

637607
# pylint:disable=client-method-missing-tracing-decorator-async
638-
async def merge_documents(
639-
self, documents: List[Dict], **kwargs: Any
640-
) -> List[IndexingResult]:
608+
async def merge_documents(self, documents: List[Dict], **kwargs: Any) -> List[IndexingResult]:
641609
"""Merge documents in to existing documents in the Azure search index.
642610
643611
Merge updates an existing document with the specified fields. If the
@@ -667,9 +635,7 @@ async def merge_documents(
667635
return cast(List[IndexingResult], results)
668636

669637
# pylint:disable=client-method-missing-tracing-decorator-async
670-
async def merge_or_upload_documents(
671-
self, documents: List[Dict], **kwargs: Any
672-
) -> List[IndexingResult]:
638+
async def merge_or_upload_documents(self, documents: List[Dict], **kwargs: Any) -> List[IndexingResult]:
673639
"""Merge documents in to existing documents in the Azure search index,
674640
or upload them if they do not yet exist.
675641
@@ -690,9 +656,7 @@ async def merge_or_upload_documents(
690656
return cast(List[IndexingResult], results)
691657

692658
@distributed_trace_async
693-
async def index_documents(
694-
self, batch: IndexDocumentsBatch, **kwargs: Any
695-
) -> List[IndexingResult]:
659+
async def index_documents(self, batch: IndexDocumentsBatch, **kwargs: Any) -> List[IndexingResult]:
696660
"""Specify a document operations to perform as a batch.
697661
698662
:param batch: A batch of document operations to perform.
@@ -703,17 +667,13 @@ async def index_documents(
703667
"""
704668
return await self._index_documents_actions(actions=batch.actions, **kwargs)
705669

706-
async def _index_documents_actions(
707-
self, actions: List[IndexAction], **kwargs: Any
708-
) -> List[IndexingResult]:
670+
async def _index_documents_actions(self, actions: List[IndexAction], **kwargs: Any) -> List[IndexingResult]:
709671
error_map = {413: RequestEntityTooLargeError}
710672

711673
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
712674
batch = IndexBatch(actions=actions)
713675
try:
714-
batch_response = await self._client.documents.index(
715-
batch=batch, error_map=error_map, **kwargs
716-
)
676+
batch_response = await self._client.documents.index(batch=batch, error_map=error_map, **kwargs)
717677
return cast(List[IndexingResult], batch_response.results)
718678
except RequestEntityTooLargeError:
719679
if len(actions) == 1:

0 commit comments

Comments
 (0)