From fcfe729af4556b52a687910f40796c67100b50ab Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Wed, 5 Jan 2022 13:02:12 -0800 Subject: [PATCH 1/4] run pyupgrade on samples --- ...sample_alternative_document_input_async.py | 10 ++--- .../sample_analyze_actions_async.py | 41 +++++++++---------- ...ample_analyze_healthcare_entities_async.py | 28 ++++++------- ...thcare_entities_with_cancellation_async.py | 2 - .../sample_analyze_sentiment_async.py | 8 ++-- ...yze_sentiment_with_opinion_mining_async.py | 2 - .../sample_authentication_async.py | 10 ++--- .../sample_detect_language_async.py | 2 - .../sample_extract_key_phrases_async.py | 2 - .../sample_extract_summary_async.py | 2 - ..._detailed_diagnostics_information_async.py | 8 ++-- .../sample_model_version_async.py | 6 +-- .../sample_multi_category_classify_async.py | 6 +-- .../sample_recognize_custom_entities_async.py | 4 +- .../sample_recognize_entities_async.py | 4 +- .../sample_recognize_linked_entities_async.py | 2 - .../sample_recognize_pii_entities_async.py | 6 +-- .../sample_single_category_classify_async.py | 4 +- .../sample_alternative_document_input.py | 10 ++--- .../samples/sample_analyze_actions.py | 40 +++++++++--------- .../sample_analyze_healthcare_entities.py | 28 ++++++------- ...e_healthcare_entities_with_cancellation.py | 2 - .../samples/sample_analyze_sentiment.py | 8 ++-- ...e_analyze_sentiment_with_opinion_mining.py | 2 - .../samples/sample_authentication.py | 10 ++--- .../samples/sample_detect_language.py | 2 - .../samples/sample_extract_key_phrases.py | 2 - .../samples/sample_extract_summary.py | 2 - ...le_get_detailed_diagnostics_information.py | 8 ++-- .../samples/sample_model_version.py | 6 +-- .../samples/sample_multi_category_classify.py | 6 +-- .../sample_recognize_custom_entities.py | 4 +- .../samples/sample_recognize_entities.py | 4 +- .../sample_recognize_linked_entities.py | 2 - .../samples/sample_recognize_pii_entities.py | 6 +-- .../sample_single_category_classify.py | 4 +- 36 files changed, 110 insertions(+), 183 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py index d55c5de0bae4..1c6e8d2e702a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -47,10 +45,10 @@ async def sample_alternative_document_input(): for idx, doc in enumerate(result): if not doc.is_error: - print("Document text: {}".format(documents[idx])) - print("Language detected: {}".format(doc.primary_language.name)) - print("ISO6391 name: {}".format(doc.primary_language.iso6391_name)) - print("Confidence score: {}\n".format(doc.primary_language.confidence_score)) + print(f"Document text: {documents[idx]}") + print(f"Language detected: {doc.primary_language.name}") + print(f"ISO6391 name: {doc.primary_language.iso6391_name}") + print(f"Confidence score: {doc.primary_language.confidence_score}\n") if doc.is_error: print(doc.id, doc.error) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_actions_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_actions_async.py index c6a73a71f1d4..ac8904143038 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_actions_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_actions_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -84,7 +82,7 @@ async def sample_analyze_async(): document_results.append(page) for doc, action_results in zip(documents, document_results): - print("\nDocument text: {}".format(doc)) + print(f"\nDocument text: {doc}") recognize_entities_result = action_results[0] print("...Results of Recognize Entities Action:") if recognize_entities_result.is_error: @@ -93,10 +91,10 @@ async def sample_analyze_async(): )) else: for entity in recognize_entities_result.entities: - print("......Entity: {}".format(entity.text)) - print(".........Category: {}".format(entity.category)) - print(".........Confidence Score: {}".format(entity.confidence_score)) - print(".........Offset: {}".format(entity.offset)) + print(f"......Entity: {entity.text}") + print(f".........Category: {entity.category}") + print(f".........Confidence Score: {entity.confidence_score}") + print(f".........Offset: {entity.offset}") recognize_pii_entities_result = action_results[1] print("...Results of Recognize PII Entities action:") @@ -106,9 +104,9 @@ async def sample_analyze_async(): )) else: for entity in recognize_pii_entities_result.entities: - print("......Entity: {}".format(entity.text)) - print(".........Category: {}".format(entity.category)) - print(".........Confidence Score: {}".format(entity.confidence_score)) + print(f"......Entity: {entity.text}") + print(f".........Category: {entity.category}") + print(f".........Confidence Score: {entity.confidence_score}") extract_key_phrases_result = action_results[2] print("...Results of Extract Key Phrases action:") @@ -117,7 +115,7 @@ async def sample_analyze_async(): extract_key_phrases_result.code, extract_key_phrases_result.message )) else: - print("......Key Phrases: {}".format(extract_key_phrases_result.key_phrases)) + print(f"......Key Phrases: {extract_key_phrases_result.key_phrases}") recognize_linked_entities_result = action_results[3] print("...Results of Recognize Linked Entities action:") @@ -127,17 +125,17 @@ async def sample_analyze_async(): )) else: for linked_entity in recognize_linked_entities_result.entities: - print("......Entity name: {}".format(linked_entity.name)) - print(".........Data source: {}".format(linked_entity.data_source)) - print(".........Data source language: {}".format(linked_entity.language)) - print(".........Data source entity ID: {}".format(linked_entity.data_source_entity_id)) - print(".........Data source URL: {}".format(linked_entity.url)) + print(f"......Entity name: {linked_entity.name}") + print(f".........Data source: {linked_entity.data_source}") + print(f".........Data source language: {linked_entity.language}") + print(f".........Data source entity ID: {linked_entity.data_source_entity_id}") + print(f".........Data source URL: {linked_entity.url}") print(".........Document matches:") for match in linked_entity.matches: - print("............Match text: {}".format(match.text)) - print("............Confidence Score: {}".format(match.confidence_score)) - print("............Offset: {}".format(match.offset)) - print("............Length: {}".format(match.length)) + print(f"............Match text: {match.text}") + print(f"............Confidence Score: {match.confidence_score}") + print(f"............Offset: {match.offset}") + print(f"............Length: {match.length}") analyze_sentiment_result = action_results[4] print("...Results of Analyze Sentiment action:") @@ -146,7 +144,7 @@ async def sample_analyze_async(): analyze_sentiment_result.code, analyze_sentiment_result.message )) else: - print("......Overall sentiment: {}".format(analyze_sentiment_result.sentiment)) + print(f"......Overall sentiment: {analyze_sentiment_result.sentiment}") print("......Scores: positive={}; neutral={}; negative={} \n".format( analyze_sentiment_result.confidence_scores.positive, analyze_sentiment_result.confidence_scores.neutral, @@ -162,4 +160,3 @@ async def main(): if __name__ == '__main__': asyncio.run(main()) - \ No newline at end of file diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py index 067cbc07e010..16746390f293 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -70,26 +68,26 @@ async def sample_analyze_healthcare_entities_async(): print("Let's first visualize the outputted healthcare result:") for idx, doc in enumerate(docs): for entity in doc.entities: - print("Entity: {}".format(entity.text)) - print("...Normalized Text: {}".format(entity.normalized_text)) - print("...Category: {}".format(entity.category)) - print("...Subcategory: {}".format(entity.subcategory)) - print("...Offset: {}".format(entity.offset)) - print("...Confidence score: {}".format(entity.confidence_score)) + print(f"Entity: {entity.text}") + print(f"...Normalized Text: {entity.normalized_text}") + print(f"...Category: {entity.category}") + print(f"...Subcategory: {entity.subcategory}") + print(f"...Offset: {entity.offset}") + print(f"...Confidence score: {entity.confidence_score}") if entity.data_sources is not None: print("...Data Sources:") for data_source in entity.data_sources: - print("......Entity ID: {}".format(data_source.entity_id)) - print("......Name: {}".format(data_source.name)) + print(f"......Entity ID: {data_source.entity_id}") + print(f"......Name: {data_source.name}") if entity.assertion is not None: print("...Assertion:") - print("......Conditionality: {}".format(entity.assertion.conditionality)) - print("......Certainty: {}".format(entity.assertion.certainty)) - print("......Association: {}".format(entity.assertion.association)) + print(f"......Conditionality: {entity.assertion.conditionality}") + print(f"......Certainty: {entity.assertion.certainty}") + print(f"......Association: {entity.assertion.association}") for relation in doc.entity_relations: - print("Relation of type: {} has the following roles".format(relation.relation_type)) + print(f"Relation of type: {relation.relation_type} has the following roles") for role in relation.roles: - print("...Role '{}' with entity '{}'".format(role.name, role.entity.text)) + print(f"...Role '{role.name}' with entity '{role.entity.text}'") print("------------------------------------------") print("Now, let's get all of medication dosage relations from the documents") diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_with_cancellation_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_with_cancellation_async.py index 80c3ea6e217b..143cae7e5fe6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_with_cancellation_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_with_cancellation_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_async.py index a8da48616a3a..9c1b87e39e7e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -65,8 +63,8 @@ async def sample_analyze_sentiment_async(): print("Let's visualize the sentiment of each of these documents") for idx, doc in enumerate(docs): - print("Document text: {}".format(documents[idx])) - print("Overall sentiment: {}".format(doc.sentiment)) + print(f"Document text: {documents[idx]}") + print(f"Overall sentiment: {doc.sentiment}") # [END analyze_sentiment_async] print("Now, let us extract all of the positive reviews") @@ -89,7 +87,7 @@ async def sample_analyze_sentiment_async(): ) positive_reviews_final = [] for idx, review in enumerate(positive_reviews): - print("Looking at positive review #{}".format(idx + 1)) + print(f"Looking at positive review #{idx + 1}") any_sentence_not_positive = False for sentence in review.sentences: print("...Sentence '{}' has sentiment '{}' with confidence scores '{}'".format( diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_with_opinion_mining_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_with_opinion_mining_async.py index c4313cbb9fea..4790041e3b43 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_with_opinion_mining_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_with_opinion_mining_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py index 3112c9f1ead1..274ee5af7fba 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -54,8 +52,8 @@ async def sample_authentication_with_api_key_credential_async(): async with text_analytics_client: result = await text_analytics_client.detect_language(doc) - print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.confidence_score)) + print(f"Language detected: {result[0].primary_language.name}") + print(f"Confidence score: {result[0].primary_language.confidence_score}") async def sample_authentication_with_azure_active_directory_async(): @@ -82,8 +80,8 @@ async def sample_authentication_with_azure_active_directory_async(): async with text_analytics_client: result = await text_analytics_client.detect_language(doc) - print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.confidence_score)) + print(f"Language detected: {result[0].primary_language.name}") + print(f"Confidence score: {result[0].primary_language.confidence_score}") async def main(): diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py index daa9470cd29b..cafb01693f85 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_key_phrases_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_key_phrases_async.py index 4c4e313badbe..69ae9c1ed008 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_key_phrases_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_key_phrases_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_summary_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_summary_async.py index 97deb7f637a3..4d0ab567466a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_summary_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_summary_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_get_detailed_diagnostics_information_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_get_detailed_diagnostics_information_async.py index 511d4c82aa69..c9db8f727fc0 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_get_detailed_diagnostics_information_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_get_detailed_diagnostics_information_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -55,7 +53,7 @@ def callback(resp): _LOGGER.debug("valid_document_count: {}".format(resp.statistics["valid_document_count"])) _LOGGER.debug("erroneous_document_count: {}".format(resp.statistics["erroneous_document_count"])) _LOGGER.debug("transaction_count: {}".format(resp.statistics["transaction_count"])) - _LOGGER.debug("model_version: {}".format(resp.model_version)) + _LOGGER.debug(f"model_version: {resp.model_version}") json_response = json.dumps(resp.raw_response) json_responses.append(json_response) @@ -67,9 +65,9 @@ def callback(resp): raw_response_hook=callback ) for doc in result: - _LOGGER.warning("Doc with id {} has these warnings: {}".format(doc.id, doc.warnings)) + _LOGGER.warning(f"Doc with id {doc.id} has these warnings: {doc.warnings}") - _LOGGER.debug("json response: {}".format(json_responses[0])) + _LOGGER.debug(f"json response: {json_responses[0]}") async def main(): diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_model_version_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_model_version_async.py index a9bd715780a0..5fc9cc5862cc 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_model_version_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_model_version_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -53,7 +51,7 @@ async def sample_model_version_async(): print("...Results of Recognize Entities:") for review in result: for entity in review.entities: - print("......Entity '{}' has category '{}'".format(entity.text, entity.category)) + print(f"......Entity '{entity.text}' has category '{entity.category}'") print("\nSetting model_version='latest' with recognize entities action in begin_analyze_actions") poller = await text_analytics_client.begin_analyze_actions( @@ -73,7 +71,7 @@ async def sample_model_version_async(): )) else: for entity in recognize_entities_result.entities: - print("......Entity '{}' has category '{}'".format(entity.text, entity.category)) + print(f"......Entity '{entity.text}' has category '{entity.category}'") async def main(): diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_multi_category_classify_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_multi_category_classify_async.py index d6d2bfc08869..0d6f9e436ef6 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_multi_category_classify_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_multi_category_classify_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -51,7 +49,7 @@ async def sample_classify_document_multi_categories_async(): ) ) - with open(path_to_sample_document, "r") as fd: + with open(path_to_sample_document) as fd: document = [fd.read()] text_analytics_client = TextAnalyticsClient( @@ -79,7 +77,7 @@ async def sample_classify_document_multi_categories_async(): for classification_result in classification_results: if not classification_result.is_error: classifications = classification_result.classifications - print("\nThe movie plot '{}' was classified as the following genres:\n".format(doc)) + print(f"\nThe movie plot '{doc}' was classified as the following genres:\n") for classification in classifications: print("'{}' with confidence score {}.".format( classification.category, classification.confidence_score diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_custom_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_custom_entities_async.py index 8bcd5cc32eaf..d80fc2aaa75b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_custom_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_custom_entities_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -54,7 +52,7 @@ async def sample_recognize_custom_entities_async(): credential=AzureKeyCredential(key), ) - with open(path_to_sample_document, "r") as fd: + with open(path_to_sample_document) as fd: document = [fd.read()] async with text_analytics_client: diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_entities_async.py index 77686604f03f..b4e33412dc16 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_entities_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -56,7 +54,7 @@ async def sample_recognize_entities_async(): for idx, review in enumerate(result): for entity in review.entities: - print("Entity '{}' has category '{}'".format(entity.text, entity.category)) + print(f"Entity '{entity.text}' has category '{entity.category}'") # [END recognize_entities_async] if entity.category == 'Organization': organization_to_reviews.setdefault(entity.text, []) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_linked_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_linked_entities_async.py index 6527ed919011..8a1222ee183d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_linked_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_linked_entities_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_pii_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_pii_entities_async.py index eeda7fec86be..b4b0b70346ac 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_pii_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_pii_entities_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -61,8 +59,8 @@ async def sample_recognize_pii_entities_async(): "I also want to comb through all of the entities that got redacted" ) for idx, doc in enumerate(docs): - print("Document text: {}".format(documents[idx])) - print("Redacted document text: {}".format(doc.redacted_text)) + print(f"Document text: {documents[idx]}") + print(f"Redacted document text: {doc.redacted_text}") for entity in doc.entities: print("...Entity '{}' with category '{}' got redacted".format( entity.text, entity.category diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_single_category_classify_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_single_category_classify_async.py index e8ca2333c316..d33a1e510464 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_single_category_classify_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_single_category_classify_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -56,7 +54,7 @@ async def sample_classify_document_single_category_async(): credential=AzureKeyCredential(key), ) - with open(path_to_sample_document, "r") as fd: + with open(path_to_sample_document) as fd: document = [fd.read()] async with text_analytics_client: diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py index 1131c77d3d6e..fbb421bb4fbc 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -49,10 +47,10 @@ def sample_alternative_document_input(): for idx, doc in enumerate(result): if not doc.is_error: - print("Document text: {}".format(documents[idx])) - print("Language detected: {}".format(doc.primary_language.name)) - print("ISO6391 name: {}".format(doc.primary_language.iso6391_name)) - print("Confidence score: {}\n".format(doc.primary_language.confidence_score)) + print(f"Document text: {documents[idx]}") + print(f"Language detected: {doc.primary_language.name}") + print(f"ISO6391 name: {doc.primary_language.iso6391_name}") + print(f"Confidence score: {doc.primary_language.confidence_score}\n") if doc.is_error: print(doc.id, doc.error) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_actions.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_actions.py index d8e51610a15f..8e1570fc82b8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_actions.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_actions.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -73,7 +71,7 @@ def sample_analyze_actions(): document_results = poller.result() for doc, action_results in zip(documents, document_results): - print("\nDocument text: {}".format(doc)) + print(f"\nDocument text: {doc}") recognize_entities_result = action_results[0] print("...Results of Recognize Entities Action:") if recognize_entities_result.is_error: @@ -82,10 +80,10 @@ def sample_analyze_actions(): )) else: for entity in recognize_entities_result.entities: - print("......Entity: {}".format(entity.text)) - print(".........Category: {}".format(entity.category)) - print(".........Confidence Score: {}".format(entity.confidence_score)) - print(".........Offset: {}".format(entity.offset)) + print(f"......Entity: {entity.text}") + print(f".........Category: {entity.category}") + print(f".........Confidence Score: {entity.confidence_score}") + print(f".........Offset: {entity.offset}") recognize_pii_entities_result = action_results[1] print("...Results of Recognize PII Entities action:") @@ -95,9 +93,9 @@ def sample_analyze_actions(): )) else: for entity in recognize_pii_entities_result.entities: - print("......Entity: {}".format(entity.text)) - print(".........Category: {}".format(entity.category)) - print(".........Confidence Score: {}".format(entity.confidence_score)) + print(f"......Entity: {entity.text}") + print(f".........Category: {entity.category}") + print(f".........Confidence Score: {entity.confidence_score}") extract_key_phrases_result = action_results[2] print("...Results of Extract Key Phrases action:") @@ -106,7 +104,7 @@ def sample_analyze_actions(): extract_key_phrases_result.code, extract_key_phrases_result.message )) else: - print("......Key Phrases: {}".format(extract_key_phrases_result.key_phrases)) + print(f"......Key Phrases: {extract_key_phrases_result.key_phrases}") recognize_linked_entities_result = action_results[3] print("...Results of Recognize Linked Entities action:") @@ -116,17 +114,17 @@ def sample_analyze_actions(): )) else: for linked_entity in recognize_linked_entities_result.entities: - print("......Entity name: {}".format(linked_entity.name)) - print(".........Data source: {}".format(linked_entity.data_source)) - print(".........Data source language: {}".format(linked_entity.language)) - print(".........Data source entity ID: {}".format(linked_entity.data_source_entity_id)) - print(".........Data source URL: {}".format(linked_entity.url)) + print(f"......Entity name: {linked_entity.name}") + print(f".........Data source: {linked_entity.data_source}") + print(f".........Data source language: {linked_entity.language}") + print(f".........Data source entity ID: {linked_entity.data_source_entity_id}") + print(f".........Data source URL: {linked_entity.url}") print(".........Document matches:") for match in linked_entity.matches: - print("............Match text: {}".format(match.text)) - print("............Confidence Score: {}".format(match.confidence_score)) - print("............Offset: {}".format(match.offset)) - print("............Length: {}".format(match.length)) + print(f"............Match text: {match.text}") + print(f"............Confidence Score: {match.confidence_score}") + print(f"............Offset: {match.offset}") + print(f"............Length: {match.length}") analyze_sentiment_result = action_results[4] print("...Results of Analyze Sentiment action:") @@ -135,7 +133,7 @@ def sample_analyze_actions(): analyze_sentiment_result.code, analyze_sentiment_result.message )) else: - print("......Overall sentiment: {}".format(analyze_sentiment_result.sentiment)) + print(f"......Overall sentiment: {analyze_sentiment_result.sentiment}") print("......Scores: positive={}; neutral={}; negative={} \n".format( analyze_sentiment_result.confidence_scores.positive, analyze_sentiment_result.confidence_scores.neutral, diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py index 994548673a86..d52d89504489 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -66,26 +64,26 @@ def sample_analyze_healthcare_entities(): print("Let's first visualize the outputted healthcare result:") for idx, doc in enumerate(docs): for entity in doc.entities: - print("Entity: {}".format(entity.text)) - print("...Normalized Text: {}".format(entity.normalized_text)) - print("...Category: {}".format(entity.category)) - print("...Subcategory: {}".format(entity.subcategory)) - print("...Offset: {}".format(entity.offset)) - print("...Confidence score: {}".format(entity.confidence_score)) + print(f"Entity: {entity.text}") + print(f"...Normalized Text: {entity.normalized_text}") + print(f"...Category: {entity.category}") + print(f"...Subcategory: {entity.subcategory}") + print(f"...Offset: {entity.offset}") + print(f"...Confidence score: {entity.confidence_score}") if entity.data_sources is not None: print("...Data Sources:") for data_source in entity.data_sources: - print("......Entity ID: {}".format(data_source.entity_id)) - print("......Name: {}".format(data_source.name)) + print(f"......Entity ID: {data_source.entity_id}") + print(f"......Name: {data_source.name}") if entity.assertion is not None: print("...Assertion:") - print("......Conditionality: {}".format(entity.assertion.conditionality)) - print("......Certainty: {}".format(entity.assertion.certainty)) - print("......Association: {}".format(entity.assertion.association)) + print(f"......Conditionality: {entity.assertion.conditionality}") + print(f"......Certainty: {entity.assertion.certainty}") + print(f"......Association: {entity.assertion.association}") for relation in doc.entity_relations: - print("Relation of type: {} has the following roles".format(relation.relation_type)) + print(f"Relation of type: {relation.relation_type} has the following roles") for role in relation.roles: - print("...Role '{}' with entity '{}'".format(role.name, role.entity.text)) + print(f"...Role '{role.name}' with entity '{role.entity.text}'") print("------------------------------------------") print("Now, let's get all of medication dosage relations from the documents") diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities_with_cancellation.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities_with_cancellation.py index 67faf378a1e0..302ad31fb2e1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities_with_cancellation.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities_with_cancellation.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment.py index 5671e2c911ec..3706529f0a0c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -64,8 +62,8 @@ def sample_analyze_sentiment(): print("Let's visualize the sentiment of each of these documents") for idx, doc in enumerate(docs): - print("Document text: {}".format(documents[idx])) - print("Overall sentiment: {}".format(doc.sentiment)) + print(f"Document text: {documents[idx]}") + print(f"Overall sentiment: {doc.sentiment}") # [END analyze_sentiment] print("Now, let us extract all of the positive reviews") @@ -88,7 +86,7 @@ def sample_analyze_sentiment(): ) positive_reviews_final = [] for idx, review in enumerate(positive_reviews): - print("Looking at positive review #{}".format(idx + 1)) + print(f"Looking at positive review #{idx + 1}") any_sentence_not_positive = False for sentence in review.sentences: print("...Sentence '{}' has sentiment '{}' with confidence scores '{}'".format( diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment_with_opinion_mining.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment_with_opinion_mining.py index 2b4afb7ee547..21ffcb45d216 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment_with_opinion_mining.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment_with_opinion_mining.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py index 58f2f1f62807..ac71855dc2a8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -52,8 +50,8 @@ def sample_authentication_with_api_key_credential(): ] result = text_analytics_client.detect_language(doc) - print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.confidence_score)) + print(f"Language detected: {result[0].primary_language.name}") + print(f"Confidence score: {result[0].primary_language.confidence_score}") def sample_authentication_with_azure_active_directory(): """DefaultAzureCredential will use the values from these environment @@ -78,8 +76,8 @@ def sample_authentication_with_azure_active_directory(): ] result = text_analytics_client.detect_language(doc) - print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.confidence_score)) + print(f"Language detected: {result[0].primary_language.name}") + print(f"Confidence score: {result[0].primary_language.confidence_score}") if __name__ == '__main__': diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py index cc181dd6a846..2eaa6a9fe5f4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_key_phrases.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_key_phrases.py index c83e096373e9..48d28e660626 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_key_phrases.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_key_phrases.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_summary.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_summary.py index 4cd606ab304f..1f10e89ec016 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_summary.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_summary.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_get_detailed_diagnostics_information.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_get_detailed_diagnostics_information.py index a880d56b658a..65fbcd5e4868 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_get_detailed_diagnostics_information.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_get_detailed_diagnostics_information.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -54,7 +52,7 @@ def callback(resp): _LOGGER.debug("valid_document_count: {}".format(resp.statistics["valid_document_count"])) _LOGGER.debug("erroneous_document_count: {}".format(resp.statistics["erroneous_document_count"])) _LOGGER.debug("transaction_count: {}".format(resp.statistics["transaction_count"])) - _LOGGER.debug("model_version: {}".format(resp.model_version)) + _LOGGER.debug(f"model_version: {resp.model_version}") json_response = json.dumps(resp.raw_response) json_responses.append(json_response) @@ -65,9 +63,9 @@ def callback(resp): raw_response_hook=callback ) for doc in result: - _LOGGER.warning("Doc with id {} has these warnings: {}".format(doc.id, doc.warnings)) + _LOGGER.warning(f"Doc with id {doc.id} has these warnings: {doc.warnings}") - _LOGGER.debug("json response: {}".format(json_responses[0])) + _LOGGER.debug(f"json response: {json_responses[0]}") if __name__ == '__main__': diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_model_version.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_model_version.py index f7608d1d24b6..af8eb4542feb 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_model_version.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_model_version.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -50,7 +48,7 @@ def sample_model_version(): print("...Results of Recognize Entities:") for review in result: for entity in review.entities: - print("......Entity '{}' has category '{}'".format(entity.text, entity.category)) + print(f"......Entity '{entity.text}' has category '{entity.category}'") print("\nSetting model_version='latest' with recognize entities action in begin_analyze_actions") poller = text_analytics_client.begin_analyze_actions( @@ -70,7 +68,7 @@ def sample_model_version(): )) else: for entity in recognize_entities_result.entities: - print("......Entity '{}' has category '{}'".format(entity.text, entity.category)) + print(f"......Entity '{entity.text}' has category '{entity.category}'") if __name__ == '__main__': diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_multi_category_classify.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_multi_category_classify.py index 8487bda97f0a..e659fe7a8ebc 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_multi_category_classify.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_multi_category_classify.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -56,7 +54,7 @@ def sample_classify_document_multi_categories(): credential=AzureKeyCredential(key), ) - with open(path_to_sample_document, "r") as fd: + with open(path_to_sample_document) as fd: document = [fd.read()] poller = text_analytics_client.begin_analyze_actions( @@ -74,7 +72,7 @@ def sample_classify_document_multi_categories(): for classification_result in classification_results: if not classification_result.is_error: classifications = classification_result.classifications - print("\nThe movie plot '{}' was classified as the following genres:\n".format(doc)) + print(f"\nThe movie plot '{doc}' was classified as the following genres:\n") for classification in classifications: print("'{}' with confidence score {}.".format( classification.category, classification.confidence_score diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_custom_entities.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_custom_entities.py index 579a603947fa..18adefccff72 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_custom_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_custom_entities.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -54,7 +52,7 @@ def sample_recognize_custom_entities(): credential=AzureKeyCredential(key), ) - with open(path_to_sample_document, "r") as fd: + with open(path_to_sample_document) as fd: document = [fd.read()] poller = text_analytics_client.begin_analyze_actions( diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_entities.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_entities.py index 4c087489c069..ea1a92e4f779 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_entities.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -54,7 +52,7 @@ def sample_recognize_entities(): for idx, review in enumerate(result): for entity in review.entities: - print("Entity '{}' has category '{}'".format(entity.text, entity.category)) + print(f"Entity '{entity.text}' has category '{entity.category}'") # [END recognize_entities] if entity.category == 'Organization': organization_to_reviews.setdefault(entity.text, []) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_linked_entities.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_linked_entities.py index ee870dfa3496..cd80dbaf5289 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_linked_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_linked_entities.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_pii_entities.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_pii_entities.py index a55a6be176f1..6a9334846123 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_pii_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_recognize_pii_entities.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -58,8 +56,8 @@ def sample_recognize_pii_entities(): "I also want to comb through all of the entities that got redacted" ) for idx, doc in enumerate(docs): - print("Document text: {}".format(documents[idx])) - print("Redacted document text: {}".format(doc.redacted_text)) + print(f"Document text: {documents[idx]}") + print(f"Redacted document text: {doc.redacted_text}") for entity in doc.entities: print("...Entity '{}' with category '{}' got redacted".format( entity.text, entity.category diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_single_category_classify.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_single_category_classify.py index 0d6f460dd9b9..c7d388ae9fee 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_single_category_classify.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_single_category_classify.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -56,7 +54,7 @@ def sample_classify_document_single_category(): credential=AzureKeyCredential(key), ) - with open(path_to_sample_document, "r") as fd: + with open(path_to_sample_document) as fd: document = [fd.read()] poller = text_analytics_client.begin_analyze_actions( From 462deb330eb6de14a7506e03735ee32f8d2db94e Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Wed, 5 Jan 2022 13:02:27 -0800 Subject: [PATCH 2/4] run pyupgrade on tests --- .../azure-ai-textanalytics/tests/conftest.py | 2 -- .../perfstress_tests/perf_detect_language.py | 1 - .../tests/test_analyze.py | 11 ++++--- .../tests/test_analyze_async.py | 9 +++--- .../tests/test_analyze_healthcare.py | 7 ++--- .../tests/test_analyze_healthcare_async.py | 7 ++--- .../tests/test_analyze_sentiment.py | 27 +++++++++-------- .../tests/test_analyze_sentiment_async.py | 27 +++++++++-------- .../azure-ai-textanalytics/tests/test_auth.py | 1 - .../tests/test_auth_async.py | 1 - .../tests/test_context_manager.py | 3 +- .../tests/test_context_manager_async.py | 3 +- .../tests/test_detect_language.py | 29 +++++++++---------- .../tests/test_detect_language_async.py | 29 +++++++++---------- .../tests/test_dict_mixin.py | 1 - .../tests/test_encoding.py | 1 - .../tests/test_encoding_async.py | 1 - .../tests/test_extract_key_phrases.py | 25 ++++++++-------- .../tests/test_extract_key_phrases_async.py | 25 ++++++++-------- .../tests/test_json_pointer.py | 1 - .../tests/test_multiapi.py | 1 - .../tests/test_multiapi_async.py | 1 - .../tests/test_recognize_entities.py | 27 +++++++++-------- .../tests/test_recognize_entities_async.py | 27 +++++++++-------- .../tests/test_recognize_linked_entities.py | 25 ++++++++-------- .../test_recognize_linked_entities_async.py | 25 ++++++++-------- .../tests/test_recognize_pii_entities.py | 27 +++++++++-------- .../test_recognize_pii_entities_async.py | 27 +++++++++-------- .../azure-ai-textanalytics/tests/test_repr.py | 9 +++--- .../azure-ai-textanalytics/tests/testcase.py | 4 +-- 30 files changed, 176 insertions(+), 208 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/conftest.py b/sdk/textanalytics/azure-ai-textanalytics/tests/conftest.py index db25760b6843..0aae4d8610ad 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/conftest.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/conftest.py @@ -1,5 +1,3 @@ - -# coding: utf-8 # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/perfstress_tests/perf_detect_language.py b/sdk/textanalytics/azure-ai-textanalytics/tests/perfstress_tests/perf_detect_language.py index 9d4d7a8f9222..d54b5ca420ba 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/perfstress_tests/perf_detect_language.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/perfstress_tests/perf_detect_language.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py index fbf5eaf21449..ecc0687755b4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ try: from unittest import mock except ImportError: # python < 3.3 - import mock # type: ignore + from unittest import mock # type: ignore from azure.core.exceptions import HttpResponseError, ClientAuthenticationError from azure.core.credentials import AzureKeyCredential @@ -282,7 +281,7 @@ def test_all_successful_passing_string_pii_entities_task(self, client): @TextAnalyticsClientPreparer() @recorded_by_proxy def test_bad_request_on_empty_document(self, client): - docs = [u""] + docs = [""] with pytest.raises(HttpResponseError): response = client.begin_analyze_actions( @@ -1250,7 +1249,7 @@ def test_generic_action_error_no_target( "./mock_test_responses/action_error_no_target.json", ) ) - with open(path_to_mock_json_response, "r") as fd: + with open(path_to_mock_json_response) as fd: mock_json_response = json.loads(fd.read()) response.text = lambda encoding=None: json.dumps(mock_json_response) @@ -1311,7 +1310,7 @@ def test_action_errors_with_targets( "./mock_test_responses/action_error_with_targets.json", ) ) - with open(path_to_mock_json_response, "r") as fd: + with open(path_to_mock_json_response) as fd: mock_json_response = json.loads(fd.read()) response.text = lambda encoding=None: json.dumps(mock_json_response) @@ -1398,7 +1397,7 @@ def test_action_job_failure( "./mock_test_responses/action_job_failure.json", ) ) - with open(path_to_mock_json_response, "r") as fd: + with open(path_to_mock_json_response) as fd: mock_json_response = json.loads(fd.read()) response.text = lambda encoding=None: json.dumps(mock_json_response) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_async.py index ebd3e8859fdf..093a846ba785 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -333,7 +332,7 @@ async def test_all_successful_passing_string_pii_entities_task(self, client): @TextAnalyticsClientPreparer() @recorded_by_proxy_async async def test_bad_request_on_empty_document(self, client): - docs = [u""] + docs = [""] with pytest.raises(HttpResponseError): async with client: @@ -1333,7 +1332,7 @@ async def test_generic_action_error_no_target( "./mock_test_responses/action_error_no_target.json", ) ) - with open(path_to_mock_json_response, "r") as fd: + with open(path_to_mock_json_response) as fd: mock_json_response = json.loads(fd.read()) response.text = lambda encoding=None: json.dumps(mock_json_response) @@ -1399,7 +1398,7 @@ async def test_action_errors_with_targets( "./mock_test_responses/action_error_with_targets.json", ) ) - with open(path_to_mock_json_response, "r") as fd: + with open(path_to_mock_json_response) as fd: mock_json_response = json.loads(fd.read()) response.text = lambda encoding=None: json.dumps(mock_json_response) @@ -1492,7 +1491,7 @@ async def test_action_job_failure( "./mock_test_responses/action_job_failure.json", ) ) - with open(path_to_mock_json_response, "r") as fd: + with open(path_to_mock_json_response) as fd: mock_json_response = json.loads(fd.read()) response.text = lambda encoding=None: json.dumps(mock_json_response) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare.py index 96f60d800375..26333e42b2d3 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -42,9 +41,9 @@ def test_no_single_input(self, client): @recorded_by_proxy def test_passing_only_string(self, client): docs = [ - u"Patient does not suffer from high blood pressure.", - u"Prescribed 100mg ibuprofen, taken twice daily.", - u"" + "Patient does not suffer from high blood pressure.", + "Prescribed 100mg ibuprofen, taken twice daily.", + "" ] response = list(client.begin_analyze_healthcare_entities(docs, polling_interval=self._interval()).result()) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare_async.py index a8bfd298f716..f69b86c36e60 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_healthcare_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -45,9 +44,9 @@ async def test_no_single_input(self, client): @recorded_by_proxy_async async def test_passing_only_string(self, client): docs = [ - u"Patient does not suffer from high blood pressure.", - u"Prescribed 100mg ibuprofen, taken twice daily.", - u"" + "Patient does not suffer from high blood pressure.", + "Prescribed 100mg ibuprofen, taken twice daily.", + "" ] async with client: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py index 562f1d568cb5..2d9b42bc1aaa 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -93,10 +92,10 @@ def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant had really good food. I recommend you try it.", - u"" + "Microsoft was founded by Bill Gates and Paul Allen.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant had really good food. I recommend you try it.", + "" ] response = client.analyze_sentiment(docs) @@ -208,7 +207,7 @@ def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = client.analyze_sentiment(docs) @@ -258,7 +257,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = client.analyze_sentiment(docs) @@ -272,9 +271,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.analyze_sentiment(docs, language="fr", raw_response_hook=callback) @@ -289,9 +288,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.analyze_sentiment(docs, language="", raw_response_hook=callback) @@ -572,7 +571,7 @@ def test_duplicate_ids_error(self, client): @recorded_by_proxy def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = client.analyze_sentiment(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py index 2af259693496..0d8aee3d2fc7 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -97,10 +96,10 @@ async def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy_async async def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant had really good food. I recommend you try it.", - u"" + "Microsoft was founded by Bill Gates and Paul Allen.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant had really good food. I recommend you try it.", + "" ] response = await client.analyze_sentiment(docs) @@ -198,7 +197,7 @@ async def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = await client.analyze_sentiment(docs) @@ -248,7 +247,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy_async async def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = await client.analyze_sentiment(docs) @@ -262,9 +261,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.analyze_sentiment(docs, language="fr", raw_response_hook=callback) @@ -279,9 +278,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.analyze_sentiment(docs, language="", raw_response_hook=callback) @@ -576,7 +575,7 @@ async def test_duplicate_ids_error(self, client): @recorded_by_proxy_async async def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = await client.analyze_sentiment(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth.py index 319f121f5115..83aa95c4504f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth_async.py index d00a3b04a50f..5c137b0cf999 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_auth_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager.py index 4cdc252825c9..1f5163ef9843 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -7,7 +6,7 @@ try: from unittest import mock except ImportError: # python < 3.3 - import mock # type: ignore + from unittest import mock # type: ignore from azure.core.credentials import AzureKeyCredential from testcase import TextAnalyticsTest, TextAnalyticsPreparer diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager_async.py index e1ff9c1bb6d6..b9b3fae06ec4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_context_manager_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -7,7 +6,7 @@ try: from unittest import mock except ImportError: # python < 3.3 - import mock # type: ignore + from unittest import mock # type: ignore import asyncio import sys diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py index a808545d3b2b..a4f8df28210d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -89,11 +88,11 @@ def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy def test_passing_only_string(self, client): docs = [ - u"I should take my cat to the veterinarian.", - u"Este es un document escrito en Español.", - u"猫は幸せ", - u"Fahrt nach Stuttgart und dann zum Hotel zu Fu.", - u"" + "I should take my cat to the veterinarian.", + "Este es un document escrito en Español.", + "猫は幸せ", + "Fahrt nach Stuttgart und dann zum Hotel zu Fu.", + "" ] response = client.detect_language(docs) @@ -188,7 +187,7 @@ def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, DetectLanguageInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = client.detect_language(docs) @@ -238,7 +237,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = client.detect_language(docs) @@ -252,9 +251,9 @@ def callback(resp): assert country == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.detect_language(docs, country_hint="CA", raw_response_hook=callback) @@ -269,9 +268,9 @@ def callback(resp): assert country == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.detect_language(docs, country_hint="", raw_response_hook=callback) @@ -544,7 +543,7 @@ def test_duplicate_ids_error(self, client): @recorded_by_proxy def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = client.detect_language(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py index dce0045e9ca5..9f9106ee7489 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -91,11 +90,11 @@ async def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy_async async def test_passing_only_string(self, client): docs = [ - u"I should take my cat to the veterinarian.", - u"Este es un document escrito en Español.", - u"猫は幸せ", - u"Fahrt nach Stuttgart und dann zum Hotel zu Fu.", - u"" + "I should take my cat to the veterinarian.", + "Este es un document escrito en Español.", + "猫は幸せ", + "Fahrt nach Stuttgart und dann zum Hotel zu Fu.", + "" ] response = await client.detect_language(docs) @@ -190,7 +189,7 @@ async def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, DetectLanguageInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above documents" + "You cannot mix string input with the above documents" ] with pytest.raises(TypeError): response = await client.detect_language(docs) @@ -240,7 +239,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy_async async def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = await client.detect_language(docs) @@ -254,9 +253,9 @@ def callback(resp): assert country == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.detect_language(docs, country_hint="CA", raw_response_hook=callback) @@ -271,9 +270,9 @@ def callback(resp): assert country == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.detect_language(docs, country_hint="", raw_response_hook=callback) @@ -546,7 +545,7 @@ async def test_duplicate_ids_error(self, client): async def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = await client.detect_language(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_dict_mixin.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_dict_mixin.py index d308488a9e03..70cce8df09eb 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_dict_mixin.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_dict_mixin.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding.py index 9d6813943bb0..a4340168ff5a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding_async.py index 950214d35480..bb1bc47edf10 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_encoding_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases.py index 6759d707ac20..cf19a4d7d64a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -69,9 +68,9 @@ def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen", - u"Microsoft fue fundado por Bill Gates y Paul Allen", - u"" + "Microsoft was founded by Bill Gates and Paul Allen", + "Microsoft fue fundado por Bill Gates y Paul Allen", + "" ] response = client.extract_key_phrases(docs) @@ -162,7 +161,7 @@ def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = client.extract_key_phrases(docs) @@ -212,7 +211,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = client.extract_key_phrases(docs) @@ -226,9 +225,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.extract_key_phrases(docs, language="fr", raw_response_hook=callback) @@ -243,9 +242,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.extract_key_phrases(docs, language="", raw_response_hook=callback) @@ -512,7 +511,7 @@ def test_duplicate_ids_error(self, client): @recorded_by_proxy def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = client.extract_key_phrases(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases_async.py index fc64e141fb21..8ea2a32a20db 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_extract_key_phrases_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -72,9 +71,9 @@ async def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy_async async def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen", - u"Microsoft fue fundado por Bill Gates y Paul Allen", - u"" + "Microsoft was founded by Bill Gates and Paul Allen", + "Microsoft fue fundado por Bill Gates y Paul Allen", + "" ] response = await client.extract_key_phrases(docs) @@ -165,7 +164,7 @@ async def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = await client.extract_key_phrases(docs) @@ -215,7 +214,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy_async async def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = await client.extract_key_phrases(docs) @@ -229,9 +228,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.extract_key_phrases(docs, language="fr", raw_response_hook=callback) @@ -246,9 +245,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.extract_key_phrases(docs, language="", raw_response_hook=callback) @@ -514,7 +513,7 @@ async def test_duplicate_ids_error(self, client): @recorded_by_proxy_async async def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = await client.extract_key_phrases(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_json_pointer.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_json_pointer.py index 8f9b3936641b..43fd407aed2f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_json_pointer.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_json_pointer.py @@ -1,4 +1,3 @@ -# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi.py index 9d404a1e524d..440360cac3e4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi_async.py index 80f9bdc3b0e0..6c5efb8a638c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_multiapi_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities.py index c86d1eff4841..daeddc8dcbeb 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -75,10 +74,10 @@ def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975.", - u"Microsoft fue fundado por Bill Gates y Paul Allen el 4 de abril de 1975.", - u"Microsoft wurde am 4. April 1975 von Bill Gates und Paul Allen gegründet.", - u"" + "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975.", + "Microsoft fue fundado por Bill Gates y Paul Allen el 4 de abril de 1975.", + "Microsoft wurde am 4. April 1975 von Bill Gates und Paul Allen gegründet.", + "" ] response = client.recognize_entities(docs) @@ -174,7 +173,7 @@ def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = client.recognize_entities(docs) @@ -224,7 +223,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = client.recognize_entities(docs) @@ -238,9 +237,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.recognize_entities(docs, language="fr", raw_response_hook=callback) @@ -255,9 +254,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.recognize_entities(docs, language="", raw_response_hook=callback) @@ -538,7 +537,7 @@ def test_duplicate_ids_error(self, client): @recorded_by_proxy def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = client.recognize_entities(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities_async.py index 9cacf164e96f..2a1dd7e42414 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_entities_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -79,10 +78,10 @@ async def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy_async async def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975.", - u"Microsoft fue fundado por Bill Gates y Paul Allen el 4 de abril de 1975.", - u"Microsoft wurde am 4. April 1975 von Bill Gates und Paul Allen gegründet.", - u"" + "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975.", + "Microsoft fue fundado por Bill Gates y Paul Allen el 4 de abril de 1975.", + "Microsoft wurde am 4. April 1975 von Bill Gates und Paul Allen gegründet.", + "" ] response = await client.recognize_entities(docs) @@ -178,7 +177,7 @@ async def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = await client.recognize_entities(docs) @@ -228,7 +227,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy_async async def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = await client.recognize_entities(docs) @@ -242,9 +241,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.recognize_entities(docs, language="fr", raw_response_hook=callback) @@ -259,9 +258,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.recognize_entities(docs, language="", raw_response_hook=callback) @@ -545,7 +544,7 @@ async def test_duplicate_ids_error(self, client): @recorded_by_proxy_async async def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = await client.recognize_entities(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities.py index b72e0b8fd620..0591ebd09020 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -81,9 +80,9 @@ def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen", - u"Microsoft fue fundado por Bill Gates y Paul Allen", - u"" + "Microsoft was founded by Bill Gates and Paul Allen", + "Microsoft fue fundado por Bill Gates y Paul Allen", + "" ] response = client.recognize_linked_entities(docs) @@ -176,7 +175,7 @@ def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = client.recognize_linked_entities(docs) @@ -226,7 +225,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = client.recognize_linked_entities(docs) @@ -240,9 +239,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.recognize_linked_entities(docs, language="fr", raw_response_hook=callback) @@ -257,9 +256,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.recognize_linked_entities(docs, language="", raw_response_hook=callback) @@ -540,7 +539,7 @@ def test_duplicate_ids_error(self, client): @recorded_by_proxy def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = client.recognize_linked_entities(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities_async.py index 680518a36810..288d3b927706 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_linked_entities_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -88,9 +87,9 @@ async def test_all_successful_passing_text_document_input(self, client): async def test_passing_only_string(self, client): docs = [ - u"Microsoft was founded by Bill Gates and Paul Allen", - u"Microsoft fue fundado por Bill Gates y Paul Allen", - u"" + "Microsoft was founded by Bill Gates and Paul Allen", + "Microsoft fue fundado por Bill Gates y Paul Allen", + "" ] response = await client.recognize_linked_entities(docs) @@ -186,7 +185,7 @@ async def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = await client.recognize_linked_entities(docs) @@ -239,7 +238,7 @@ def callback(response): @recorded_by_proxy_async async def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = await client.recognize_linked_entities(docs) @@ -254,9 +253,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.recognize_linked_entities(docs, language="fr", raw_response_hook=callback) @@ -272,9 +271,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.recognize_linked_entities(docs, language="", raw_response_hook=callback) @@ -563,7 +562,7 @@ async def test_duplicate_ids_error(self, client): @recorded_by_proxy_async async def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = await client.recognize_linked_entities(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py index e6a38db8f26c..510ea2a2b56a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -93,10 +92,10 @@ def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy def test_passing_only_string(self, client): docs = [ - u"My SSN is 859-98-0987.", - u"Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.", - u"Is 998.214.865-68 your Brazilian CPF number?", - u"" + "My SSN is 859-98-0987.", + "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.", + "Is 998.214.865-68 your Brazilian CPF number?", + "" ] response = client.recognize_pii_entities(docs, show_stats=True) @@ -199,7 +198,7 @@ def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = client.recognize_pii_entities(docs) @@ -249,7 +248,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = client.recognize_pii_entities(docs) @@ -263,9 +262,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.recognize_pii_entities(docs, language="fr", raw_response_hook=callback) @@ -280,9 +279,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = client.recognize_pii_entities(docs, language="", raw_response_hook=callback) @@ -563,7 +562,7 @@ def test_duplicate_ids_error(self, client): @recorded_by_proxy def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = client.recognize_pii_entities(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py index c87197455646..a2136ea11b0b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -95,10 +94,10 @@ async def test_all_successful_passing_text_document_input(self, client): @recorded_by_proxy_async async def test_passing_only_string(self, client): docs = [ - u"My SSN is 859-98-0987.", - u"Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.", - u"Is 998.214.865-68 your Brazilian CPF number?", - u"" + "My SSN is 859-98-0987.", + "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.", + "Is 998.214.865-68 your Brazilian CPF number?", + "" ] response = await client.recognize_pii_entities(docs, show_stats=True) @@ -201,7 +200,7 @@ async def test_mixing_inputs(self, client): docs = [ {"id": "1", "text": "Microsoft was founded by Bill Gates and Paul Allen."}, TextDocumentInput(id="2", text="I did not like the hotel we stayed at. It was too expensive."), - u"You cannot mix string input with the above inputs" + "You cannot mix string input with the above inputs" ] with pytest.raises(TypeError): response = await client.recognize_pii_entities(docs) @@ -251,7 +250,7 @@ def callback(response): @TextAnalyticsClientPreparer() @recorded_by_proxy_async async def test_batch_size_over_limit(self, client): - docs = [u"hello world"] * 1050 + docs = ["hello world"] * 1050 with pytest.raises(HttpResponseError): response = await client.recognize_pii_entities(docs) @@ -265,9 +264,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.recognize_pii_entities(docs, language="fr", raw_response_hook=callback) @@ -282,9 +281,9 @@ def callback(resp): assert language == 3 docs = [ - u"This was the best day of my life.", - u"I did not like the hotel we stayed at. It was too expensive.", - u"The restaurant was not as good as I hoped." + "This was the best day of my life.", + "I did not like the hotel we stayed at. It was too expensive.", + "The restaurant was not as good as I hoped." ] response = await client.recognize_pii_entities(docs, language="", raw_response_hook=callback) @@ -565,7 +564,7 @@ async def test_duplicate_ids_error(self, client): @recorded_by_proxy_async async def test_batch_size_over_limit_error(self, client): # Batch size over limit - docs = [u"hello world"] * 1001 + docs = ["hello world"] * 1001 try: response = await client.recognize_pii_entities(docs) except HttpResponseError as err: diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_repr.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_repr.py index 8a49ee02a149..9778cbc66dfd 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_repr.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_repr.py @@ -1,4 +1,3 @@ -# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -190,7 +189,7 @@ def mined_opinion(target_sentiment, assessment_sentiment): target=target_sentiment[0], assessments=[assessment_sentiment[0]] ) - model_repr = "MinedOpinion(target={}, assessments=[{}])".format(target_sentiment[1], assessment_sentiment[1]) + model_repr = f"MinedOpinion(target={target_sentiment[1]}, assessments=[{assessment_sentiment[1]}])" assert repr(model) == model_repr return model, model_repr @@ -314,7 +313,7 @@ def healthcare_relation_role(healthcare_entity): entity=healthcare_entity[0] ) - model_repr = "HealthcareRelationRole(name=ROLE, entity={})".format(healthcare_entity[1]) + model_repr = f"HealthcareRelationRole(name=ROLE, entity={healthcare_entity[1]})" assert repr(model) == model_repr return model, model_repr @@ -326,7 +325,7 @@ def healthcare_relation(healthcare_relation_role): roles=[healthcare_relation_role[0]] ) - model_repr = "HealthcareRelation(relation_type=DOSAGE, roles=[{}])".format(healthcare_relation_role[1]) + model_repr = f"HealthcareRelation(relation_type=DOSAGE, roles=[{healthcare_relation_role[1]}])" assert repr(model) == model_repr return model, model_repr @@ -358,7 +357,7 @@ def test_document_error(self, text_analytics_error): error=text_analytics_error[0], is_error=True ) - model_repr = "DocumentError(id=1, error={}, is_error=True)".format(text_analytics_error[1]) + model_repr = f"DocumentError(id=1, error={text_analytics_error[1]}, is_error=True)" assert repr(model) == model_repr diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py b/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py index 8bf0d388b8ed..4bc41afe5cd2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py @@ -1,5 +1,3 @@ - -# coding: utf-8 # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -42,7 +40,7 @@ class TextAnalyticsClientPreparer(AzureMgmtPreparer): def __init__(self, client_cls, client_kwargs={}, **kwargs): - super(TextAnalyticsClientPreparer, self).__init__( + super().__init__( name_prefix='', random_name_length=42 ) From fe2688c748f39f2ffa158cddc6f429b2b9be80a7 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Wed, 5 Jan 2022 13:02:44 -0800 Subject: [PATCH 3/4] run pyupgrade on src code --- .../azure/ai/textanalytics/__init__.py | 1 - .../azure/ai/textanalytics/_base_client.py | 3 +-- .../azure/ai/textanalytics/_lro.py | 11 +++++------ .../azure/ai/textanalytics/_models.py | 7 +++---- .../azure/ai/textanalytics/_policies.py | 3 +-- .../azure/ai/textanalytics/_request_handlers.py | 7 +++---- .../azure/ai/textanalytics/_response_handlers.py | 11 +++++------ .../azure/ai/textanalytics/_text_analytics_client.py | 3 +-- .../azure/ai/textanalytics/_user_agent.py | 3 +-- .../azure/ai/textanalytics/_version.py | 1 - .../azure/ai/textanalytics/aio/__init__.py | 1 - .../azure/ai/textanalytics/aio/_base_client_async.py | 3 +-- .../azure/ai/textanalytics/aio/_lro_async.py | 5 ++--- .../ai/textanalytics/aio/_response_handlers_async.py | 1 - .../textanalytics/aio/_text_analytics_client_async.py | 3 +-- 15 files changed, 24 insertions(+), 39 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/__init__.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/__init__.py index c9812c7241cd..e1f6d78cb40e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/__init__.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/__init__.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py index 09cd62bb3a3d..1072cce3f5be 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -37,7 +36,7 @@ def _authentication_policy(credential): return authentication_policy -class TextAnalyticsClientBase(object): +class TextAnalyticsClientBase: def __init__(self, endpoint, credential, **kwargs): http_logging_policy = HttpLoggingPolicy(**kwargs) http_logging_policy.allowed_header_names.update( diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_lro.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_lro.py index 00c0ca51aee1..e5457b6191d1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_lro.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_lro.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -32,7 +31,7 @@ class TextAnalyticsOperationResourcePolling(OperationResourcePolling): def __init__( self, operation_location_header="operation-location", show_stats=False ): - super(TextAnalyticsOperationResourcePolling, self).__init__( + super().__init__( operation_location_header=operation_location_header ) self._show_stats = show_stats @@ -40,10 +39,10 @@ def __init__( def get_polling_url(self): if not self._show_stats: - return super(TextAnalyticsOperationResourcePolling, self).get_polling_url() + return super().get_polling_url() return ( - super(TextAnalyticsOperationResourcePolling, self).get_polling_url() + super().get_polling_url() + "?" + urlencode(self._query_params) ) @@ -124,7 +123,7 @@ def __init__(self, *args, **kwargs): self._doc_id_order = kwargs.pop("doc_id_order", None) self._show_stats = kwargs.pop("show_stats", None) self._text_analytics_client = kwargs.pop("text_analytics_client") - super(AnalyzeHealthcareEntitiesLROPollingMethod, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) @property def _current_body(self): @@ -273,7 +272,7 @@ def __init__(self, *args, **kwargs): self._doc_id_order = kwargs.pop("doc_id_order", None) self._task_id_order = kwargs.pop("task_id_order", None) self._show_stats = kwargs.pop("show_stats", None) - super(AnalyzeActionsLROPollingMethod, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) @property def _current_body(self): diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py index 2a23da510623..cbf0c4deeb09 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py @@ -1,4 +1,3 @@ -# coding=utf-8 pylint: disable=too-many-lines # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -1199,7 +1198,7 @@ def __getattr__(self, attr): ) ) raise AttributeError( - "'DocumentError' object has no attribute '{}'".format(attr) + f"'DocumentError' object has no attribute '{attr}'" ) @classmethod @@ -1239,7 +1238,7 @@ class DetectLanguageInput(LanguageInput): """ def __init__(self, **kwargs): - super(DetectLanguageInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = kwargs.get("id", None) self.text = kwargs.get("text", None) self.country_hint = kwargs.get("country_hint", None) @@ -1390,7 +1389,7 @@ class TextDocumentInput(DictMixin, MultiLanguageInput): """ def __init__(self, **kwargs): - super(TextDocumentInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = kwargs.get("id", None) self.text = kwargs.get("text", None) self.language = kwargs.get("language", None) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_policies.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_policies.py index a442833c2d7d..8620b9bd32e7 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_policies.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_policies.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ class TextAnalyticsResponseHookPolicy(SansIOHTTPPolicy): def __init__(self, **kwargs): self._response_callback = kwargs.get("raw_response_hook") self._is_lro = None - super(TextAnalyticsResponseHookPolicy, self).__init__() + super().__init__() def on_request(self, request): self._response_callback = request.context.options.pop( diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py index 497e12a361fa..9c2e526e6c3c 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -35,13 +34,13 @@ def _validate_input(documents, hint, whole_input_hint): if not documents: raise ValueError("Input documents can not be empty or None") - if isinstance(documents, six.string_types): + if isinstance(documents, str): raise TypeError("Input documents cannot be a string.") if isinstance(documents, dict): raise TypeError("Input documents cannot be a dict") - if not all(isinstance(x, six.string_types) for x in documents): + if not all(isinstance(x, str) for x in documents): if not all( isinstance(x, (dict, TextDocumentInput, DetectLanguageInput)) for x in documents @@ -52,7 +51,7 @@ def _validate_input(documents, hint, whole_input_hint): request_batch = [] for idx, doc in enumerate(documents): - if isinstance(doc, six.string_types): + if isinstance(doc, str): if hint == "country_hint" and whole_input_hint.lower() == "none": whole_input_hint = "" document = {"id": str(idx), hint: whole_input_hint, "text": doc} diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_response_handlers.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_response_handlers.py index 438ed6c3597c..99fae2901827 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_response_handlers.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_response_handlers.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -46,11 +45,11 @@ class CSODataV4Format(ODataV4Format): def __init__(self, odata_error): try: if odata_error["error"]["innererror"]: - super(CSODataV4Format, self).__init__( + super().__init__( odata_error["error"]["innererror"] ) except KeyError: - super(CSODataV4Format, self).__init__(odata_error) + super().__init__(odata_error) def process_http_response_error(error): @@ -367,14 +366,14 @@ def get_task_from_pointer(task_type): # pylint: disable=too-many-return-stateme def resolve_action_pointer(pointer): import re pointer_union = "|".join(value for value in ActionPointerKind) - found = re.search(r"#/tasks/({})/\d+".format(pointer_union), pointer) + found = re.search(fr"#/tasks/({pointer_union})/\d+", pointer) if found: index = int(pointer[-1]) task = pointer.split("#/tasks/")[1].split("/")[0] property_name = get_task_from_pointer(task) return property_name, index raise ValueError( - "Unexpected response from service - action pointer '{}' is not a valid action pointer.".format(pointer) + f"Unexpected response from service - action pointer '{pointer}' is not a valid action pointer." ) @@ -382,7 +381,7 @@ def get_ordered_errors(tasks_obj, task_name, doc_id_order): # throw exception if error missing a target missing_target = any([error for error in tasks_obj.errors if error.target is None]) if missing_target: - message = "".join(["({}) {}".format(err.code, err.message) for err in tasks_obj.errors]) + message = "".join([f"({err.code}) {err.message}" for err in tasks_obj.errors]) raise HttpResponseError(message=message) # create a DocumentError per input doc with the action error details diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py index f17d9ef5dd12..00f2f029c50d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -118,7 +117,7 @@ class TextAnalyticsClient(TextAnalyticsClientBase): def __init__(self, endpoint, credential, **kwargs): # type: (str, Union[AzureKeyCredential, TokenCredential], Any) -> None - super(TextAnalyticsClient, self).__init__( + super().__init__( endpoint=endpoint, credential=credential, **kwargs ) self._api_version = kwargs.get("api_version", DEFAULT_API_VERSION) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_user_agent.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_user_agent.py index d45e7b96a832..cb1d5fe03e42 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_user_agent.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_user_agent.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -6,4 +5,4 @@ from ._version import VERSION -USER_AGENT = "ai-textanalytics/{}".format(VERSION) +USER_AGENT = f"ai-textanalytics/{VERSION}" diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_version.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_version.py index 164878621003..093f19e1ad6e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_version.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_version.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/__init__.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/__init__.py index 766fbc0bb994..ed3956fa7bdb 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/__init__.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/__init__.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_base_client_async.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_base_client_async.py index 5e5514254256..cc45d397a815 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_base_client_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_base_client_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -28,7 +27,7 @@ def _authentication_policy(credential): return authentication_policy -class AsyncTextAnalyticsClientBase(object): +class AsyncTextAnalyticsClientBase: def __init__(self, endpoint, credential, **kwargs): http_logging_policy = HttpLoggingPolicy(**kwargs) http_logging_policy.allowed_header_names.update( diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_lro_async.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_lro_async.py index af0a0807c088..494f94ac1100 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_lro_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_lro_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -96,7 +95,7 @@ def __init__(self, *args, **kwargs): self._text_analytics_client = kwargs.pop("text_analytics_client") self._doc_id_order = kwargs.pop("doc_id_order", None) self._show_stats = kwargs.pop("show_stats", None) - super(AsyncAnalyzeHealthcareEntitiesLROPollingMethod, self).__init__( + super().__init__( *args, **kwargs ) @@ -242,7 +241,7 @@ def __init__(self, *args, **kwargs): self._doc_id_order = kwargs.pop("doc_id_order", None) self._task_id_order = kwargs.pop("task_id_order", None) self._show_stats = kwargs.pop("show_stats", None) - super(AsyncAnalyzeActionsLROPollingMethod, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) @property def _current_body(self): diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_response_handlers_async.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_response_handlers_async.py index d5aef7b4d8cb..e7c55f87fcdf 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_response_handlers_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_response_handlers_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py index e751ce5813c7..7fcdc290a242 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py @@ -1,4 +1,3 @@ -# coding=utf-8 # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -116,7 +115,7 @@ def __init__( # type: ignore credential: Union["AzureKeyCredential", "AsyncTokenCredential"], **kwargs: Any, ) -> None: - super(TextAnalyticsClient, self).__init__( + super().__init__( endpoint=endpoint, credential=credential, **kwargs ) self._api_version = kwargs.get("api_version", DEFAULT_API_VERSION) From 438b10560ddb5912e98108e6c49df17b964b60dd Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Thu, 6 Jan 2022 10:23:38 -0800 Subject: [PATCH 4/4] fix mock import and pylint --- .../azure/ai/textanalytics/_models.py | 1 + .../azure/ai/textanalytics/_request_handlers.py | 1 - .../azure-ai-textanalytics/tests/test_analyze.py | 6 +----- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py index cbf0c4deeb09..e9d5512ac6fe 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py index 9c2e526e6c3c..62187f2611b8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_request_handlers.py @@ -4,7 +4,6 @@ # ------------------------------------ -import six from ._generated.models import ( EntitiesTask, PiiTask, diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py index ecc0687755b4..68a881d0537d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze.py @@ -11,11 +11,7 @@ import itertools import datetime import json -try: - from unittest import mock -except ImportError: # python < 3.3 - from unittest import mock # type: ignore - +from unittest import mock from azure.core.exceptions import HttpResponseError, ClientAuthenticationError from azure.core.credentials import AzureKeyCredential from testcase import TextAnalyticsTest, TextAnalyticsPreparer