From 85cdf05ca8acbdc7bb21e77adebb54dea6f6539c Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 26 Feb 2024 09:36:16 +0200 Subject: [PATCH] review formatting --- pr_agent/algo/utils.py | 9 +++++---- tests/unittest/test_convert_to_markdown.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 09a6a39b..ef2e5712 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -63,13 +63,13 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: emoji = emojis.get(key_nice, "") if gfm_supported: if 'Estimated effort to review' in key_nice: - key_nice = 'Estimated effort to review [1-5]' + key_nice = 'Estimated effort to review [1-5]' if 'possible issues' in key_nice.lower(): value = value.strip() issues = value.split('\n- ') number_of_issues = len(issues) if number_of_issues > 1: - markdown_text += f" {emoji} {key_nice}\n" + markdown_text += f" {emoji} {key_nice}\n" for i, issue in enumerate(issues): issue = issue.strip('-').strip() if i == 0: @@ -77,9 +77,10 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: else: markdown_text += f"\n\n\n{issue}\n" else: - markdown_text += f" {emoji} {key_nice}\n\n{value}\n\n\n" + value = value.strip('-').strip() + markdown_text += f" {emoji} {key_nice}\n\n{value}\n\n\n" else: - markdown_text += f" {emoji} {key_nice}\n\n{value}\n\n\n" + markdown_text += f" {emoji} {key_nice}\n\n{value}\n\n\n" else: if len(value.split()) > 1: markdown_text += f"{emoji} **{key_nice}:**\n\n {value}\n\n" diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py index 0b0af128..5337ac6b 100644 --- a/tests/unittest/test_convert_to_markdown.py +++ b/tests/unittest/test_convert_to_markdown.py @@ -52,7 +52,7 @@ class TestConvertToMarkdown: 'suggestion': "Consider raising an exception or logging a warning when 'pr_url' attribute is not found. This can help in debugging issues related to the absence of 'pr_url' in instances where it's expected. [important]\n", 'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]} - expected_output = '## PR Review\n\n\n\n\n\n\n\n
     PR feedback                    
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
๐Ÿ” Possible issues\n\nNo\n\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' + expected_output = '## PR Review\n\n\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
๐Ÿ” Possible issues\n\nNo\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' assert convert_to_markdown(input_data).strip() == expected_output.strip()