From d404087e8c3e4b5b584c35ffbc4ba43cbce2e6ba Mon Sep 17 00:00:00 2001 From: cs_lucky Date: Mon, 23 Oct 2023 17:25:29 +0800 Subject: [PATCH] fix comments in template --- src/promptflow/promptflow/_utils/connection_utils.py | 4 ++-- .../executor/unittests/_utils/test_connection_utils.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/promptflow/promptflow/_utils/connection_utils.py b/src/promptflow/promptflow/_utils/connection_utils.py index 5ea3cb6ff4d..66ed5b9cfb8 100644 --- a/src/promptflow/promptflow/_utils/connection_utils.py +++ b/src/promptflow/promptflow/_utils/connection_utils.py @@ -114,9 +114,9 @@ def extract_comments_mapping(keys, doc): param_pattern = rf":param {key}: (.*)" key_description = " ".join(re.findall(param_pattern, doc)) type_pattern = rf":type {key}: (.*)" - key_type = " ".join(re.findall(type_pattern, doc)).rstrip(".") + key_type = " ".join(re.findall(type_pattern, doc)).rstrip(".") + " type." if key_type and key_description: - comments_map[key] = ", ".join([key_type, key_description]) + comments_map[key] = " ".join([key_type, key_description]) elif key_type: comments_map[key] = key_type elif key_description: diff --git a/src/promptflow/tests/executor/unittests/_utils/test_connection_utils.py b/src/promptflow/tests/executor/unittests/_utils/test_connection_utils.py index a17677f910f..3d6f76ed909 100644 --- a/src/promptflow/tests/executor/unittests/_utils/test_connection_utils.py +++ b/src/promptflow/tests/executor/unittests/_utils/test_connection_utils.py @@ -62,12 +62,12 @@ class TestConnectionUtils: ( MyCustomConnectionWithInvalidComments, [ - 'api_base: "to_replace_with_api_base" # String, The api base.\n', - 'api_key: "to_replace_with_api_key" # String, The api key.\n', + 'api_base: "to_replace_with_api_base" # String type. The api base.\n', + 'api_key: "to_replace_with_api_key" # String type. The api key.\n', ], ), (MyCustomConnectionMissingTypeComments, ['api_key: "to_replace_with_api_key" # The api key.']), - (MyCustomConnectionMissingParamComments, ['api_key: "to_replace_with_api_key" # String']), + (MyCustomConnectionMissingParamComments, ['api_key: "to_replace_with_api_key" # String type.']), ], ) def test_generate_custom_strong_type_connection_template_with_comments(self, cls, expected_str_in_template):