diff --git a/dialogflow/analyze_content_stream_test.py b/dialogflow/analyze_content_stream_test.py index e9e226a2fe22..29aa40b0fa13 100644 --- a/dialogflow/analyze_content_stream_test.py +++ b/dialogflow/analyze_content_stream_test.py @@ -21,7 +21,6 @@ import conversation_profile_management import participant_management - PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") AUDIO_FILE_PATH = "{0}/resources/book_a_room.wav".format( os.path.realpath(os.path.dirname(__file__)), @@ -37,8 +36,7 @@ def conversation_profile_display_name(): def conversation_profile_id(conversation_profile_display_name): # Create conversation profile. response = conversation_profile_management.create_conversation_profile_article_faq( - project_id=PROJECT_ID, - display_name=conversation_profile_display_name + project_id=PROJECT_ID, display_name=conversation_profile_display_name ) conversation_profile_id = response.name.split("conversationProfiles/")[1].rstrip() @@ -61,7 +59,9 @@ def conversation_id(conversation_profile_id): yield conversation_id # Complete the conversation. - conversation_management.complete_conversation(project_id=PROJECT_ID, conversation_id=conversation_id) + conversation_management.complete_conversation( + project_id=PROJECT_ID, conversation_id=conversation_id + ) @pytest.fixture @@ -79,7 +79,7 @@ def test_analyze_content_audio_stream(capsys, conversation_id, participant_id): participant_management.analyze_content_audio_stream( project_id=PROJECT_ID, conversation_id=conversation_id, - participant_id=participant_id , + participant_id=participant_id, audio_file_path=AUDIO_FILE_PATH, ) out, _ = capsys.readouterr() diff --git a/dialogflow/answer_record_management_test.py b/dialogflow/answer_record_management_test.py index 5008c077dd57..51d109f99ecf 100644 --- a/dialogflow/answer_record_management_test.py +++ b/dialogflow/answer_record_management_test.py @@ -26,8 +26,7 @@ def test_smart_reply(capsys): - """Test smart reply feature. - """ + """Test smart reply feature.""" # Create conversation profile. conversation_profile_management.create_conversation_profile_smart_reply( diff --git a/dialogflow/conversation_profile_management.py b/dialogflow/conversation_profile_management.py index 1316ceab12ae..aed0ce6ddae5 100644 --- a/dialogflow/conversation_profile_management.py +++ b/dialogflow/conversation_profile_management.py @@ -139,7 +139,10 @@ def create_conversation_profile_smart_reply( } feature_config = { "suggestion_feature": {"type_": "SMART_REPLY"}, - "suggestion_trigger_settings": {"no_small_talk": True, "only_end_user": True, }, + "suggestion_trigger_settings": { + "no_small_talk": True, + "only_end_user": True, + }, "query_config": { "document_query_source": {"documents": [smart_reply_allowlist_name]}, "max_results": 3, diff --git a/dialogflow/create_document_test.py b/dialogflow/create_document_test.py index db4c4ea9c47f..fed3c914e035 100644 --- a/dialogflow/create_document_test.py +++ b/dialogflow/create_document_test.py @@ -18,7 +18,6 @@ import uuid from google.cloud import dialogflow_v2beta1 as dialogflow - import pytest import document_management diff --git a/dialogflow/detect_intent_audio.py b/dialogflow/detect_intent_audio.py index e0cbd78fc899..6c398168713e 100644 --- a/dialogflow/detect_intent_audio.py +++ b/dialogflow/detect_intent_audio.py @@ -58,7 +58,9 @@ def detect_intent_audio(project_id, session_id, audio_file_path, language_code): query_input = dialogflow.QueryInput(audio_config=audio_config) request = dialogflow.DetectIntentRequest( - session=session, query_input=query_input, input_audio=input_audio, + session=session, + query_input=query_input, + input_audio=input_audio, ) response = session_client.detect_intent(request=request) diff --git a/dialogflow/document_management.py b/dialogflow/document_management.py index 8957ee034040..33697862edf6 100644 --- a/dialogflow/document_management.py +++ b/dialogflow/document_management.py @@ -35,7 +35,6 @@ import argparse - KNOWLEDGE_TYPES = [ "KNOWLEDGE_TYPE_UNSPECIFIED", "FAQ", diff --git a/dialogflow/list_training_phrases_test.py b/dialogflow/list_training_phrases_test.py index 871a94fc683c..820441bfde46 100644 --- a/dialogflow/list_training_phrases_test.py +++ b/dialogflow/list_training_phrases_test.py @@ -18,13 +18,13 @@ import list_training_phrases - _, PROJECT_ID = google.auth.default() INTENT_ID = "7b5bd47e-6dd9-4b45-8624-565862bd2d85" def test_list_training_phrases(capsys): training_phrases = list_training_phrases.list_training_phrases( - PROJECT_ID, INTENT_ID, + PROJECT_ID, + INTENT_ID, ) assert len(training_phrases) >= 9 # Number of training phrases at this point. diff --git a/dialogflow/noxfile.py b/dialogflow/noxfile.py index f5c32b22789b..0577084695fc 100644 --- a/dialogflow/noxfile.py +++ b/dialogflow/noxfile.py @@ -22,7 +22,6 @@ import nox - # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING # DO NOT EDIT THIS FILE EVER! @@ -160,6 +159,7 @@ def blacken(session: nox.sessions.Session) -> None: # format = isort + black # + @nox.session def format(session: nox.sessions.Session) -> None: """ @@ -187,7 +187,9 @@ def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: # check for presence of tests - test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob("**/test_*.py", recursive=True) + test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob( + "**/test_*.py", recursive=True + ) test_list.extend(glob.glob("**/tests", recursive=True)) if len(test_list) == 0: @@ -209,9 +211,7 @@ def _session_tests( if os.path.exists("requirements-test.txt"): if os.path.exists("constraints-test.txt"): - session.install( - "-r", "requirements-test.txt", "-c", "constraints-test.txt" - ) + session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") else: session.install("-r", "requirements-test.txt") with open("requirements-test.txt") as rtfile: @@ -224,9 +224,9 @@ def _session_tests( post_install(session) if "pytest-parallel" in packages: - concurrent_args.extend(['--workers', 'auto', '--tests-per-worker', 'auto']) + concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"]) elif "pytest-xdist" in packages: - concurrent_args.extend(['-n', 'auto']) + concurrent_args.extend(["-n", "auto"]) session.run( "pytest", @@ -256,7 +256,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): diff --git a/dialogflow/participant_management.py b/dialogflow/participant_management.py index 7df3ae99c134..e2bf6169f433 100644 --- a/dialogflow/participant_management.py +++ b/dialogflow/participant_management.py @@ -111,7 +111,9 @@ def analyze_content_text(project_id, conversation_id, participant_id, text): # [END dialogflow_analyze_content_text] # [START dialogflow_analyze_content_audio_stream] -def analyze_content_audio_stream(project_id, conversation_id, participant_id, audio_file_path): +def analyze_content_audio_stream( + project_id, conversation_id, participant_id, audio_file_path +): """Analyze audio content for END_USER Args: @@ -156,12 +158,12 @@ def request_generator(audio_config, audio_file_path): audio_config = dialogflow.InputAudioConfig( audio_encoding=audio_encoding, - language_code='en-US', + language_code="en-US", sample_rate_hertz=sample_rate_hertz, single_utterance=True, - model='phone_call', + model="phone_call", # Make sure your project is Dialogflow ES ENTERPRISE_TIER in order to "USE_ENHANCED" model. - model_variant='USE_ENHANCED' + model_variant="USE_ENHANCED", ) requests = request_generator(audio_config, audio_file_path) responses = client.streaming_analyze_content(requests=requests) @@ -171,4 +173,5 @@ def request_generator(audio_config, audio_file_path): print("=" * 20) + # [END dialogflow_analyze_content_audio_stream] diff --git a/dialogflow/participant_management_test.py b/dialogflow/participant_management_test.py index fc2754790969..6e4fd7e78f1e 100644 --- a/dialogflow/participant_management_test.py +++ b/dialogflow/participant_management_test.py @@ -27,8 +27,7 @@ def test_analyze_content_text(capsys): - """Test analyze content api with text only messages. - """ + """Test analyze content api with text only messages.""" # Create knowledge base. knowledge_base_management.create_knowledge_base( PROJECT_ID, KNOWLEDGE_BASE_DISPLAY_NAME diff --git a/dialogflow/set_agent.py b/dialogflow/set_agent.py index f1b993d1526f..c252a131a000 100644 --- a/dialogflow/set_agent.py +++ b/dialogflow/set_agent.py @@ -14,8 +14,7 @@ # [START dialogflow_set_agent_sample] -from google.cloud.dialogflow_v2 import Agent -from google.cloud.dialogflow_v2 import AgentsClient +from google.cloud.dialogflow_v2 import Agent, AgentsClient def set_agent(project_id, display_name): diff --git a/dialogflow/set_agent_test.py b/dialogflow/set_agent_test.py index 98b0eeb7fef4..aff0dcdf2a70 100644 --- a/dialogflow/set_agent_test.py +++ b/dialogflow/set_agent_test.py @@ -15,7 +15,6 @@ import os from google.api_core.exceptions import InvalidArgument - import pytest from set_agent import set_agent diff --git a/dialogflow/update_intent_test.py b/dialogflow/update_intent_test.py index 432c0531f201..f28f4b304aec 100644 --- a/dialogflow/update_intent_test.py +++ b/dialogflow/update_intent_test.py @@ -18,7 +18,6 @@ from google.cloud.dialogflow_v2.services.agents.client import AgentsClient from google.cloud.dialogflow_v2.services.intents.client import IntentsClient from google.cloud.dialogflow_v2.types.intent import Intent - import pytest from update_intent import update_intent diff --git a/dialogflow/webhook.py b/dialogflow/webhook.py index 0299170ca823..b3cdbe35dbe7 100644 --- a/dialogflow/webhook.py +++ b/dialogflow/webhook.py @@ -17,6 +17,7 @@ # TODO: change the default Entry Point text to handleWebhook + def handleWebhook(request): req = request.get_json()