From 7047248b6e282b80e27f111d06f81bacfb247bc6 Mon Sep 17 00:00:00 2001 From: Jake Adams Date: Wed, 5 Mar 2025 15:04:08 -0700 Subject: [PATCH] Fix lint errors and remove obsolete code. --- issue_metrics.py | 2 ++ test_issue_metrics.py | 37 +++++++++++++------------------------ 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/issue_metrics.py b/issue_metrics.py index c46a4cf..1a3d63d 100644 --- a/issue_metrics.py +++ b/issue_metrics.py @@ -166,6 +166,7 @@ def get_per_issue_metrics( return issues_with_metrics, num_issues_open, num_issues_closed + def evaluate_markdown_file_size(output_file: str) -> None: file_name_without_extension = Path(output_file).stem max_char_count = 65535 @@ -180,6 +181,7 @@ def evaluate_markdown_file_size(output_file: str) -> None: See https://github.com/github/issue-metrics/blob/main/docs/dealing-with-large-issue-metrics.md" ) + def main(): # pragma: no cover """Run the issue-metrics script. diff --git a/test_issue_metrics.py b/test_issue_metrics.py index b02dde8..4f67d39 100644 --- a/test_issue_metrics.py +++ b/test_issue_metrics.py @@ -177,7 +177,6 @@ def test_get_per_issue_metrics_with_hide_envs(self): "HIDE_TIME_TO_ANSWER": "false", "HIDE_TIME_TO_CLOSE": "false", "HIDE_TIME_TO_FIRST_RESPONSE": "false", - "OUTPUT_FILE": "test_issue_metrics.md" }, ) def test_get_per_issue_metrics_without_hide_envs(self): @@ -483,16 +482,10 @@ def test_get_per_issue_metrics_with_discussion_with_hide_envs(self): class TestEvaluateMarkdownFileSize(unittest.TestCase): """Test suite for the evaluate_markdown_file_size function.""" - @patch.dict( - os.environ, - { - "GH_TOKEN": "test_token", - "SEARCH_QUERY": "is:issue is:open repo:user/repo", - "OUTPUT_FILE": "test_issue_metrics.md" - } - ) @patch("issue_metrics.markdown_too_large_for_issue_body") - def test_markdown_too_large_for_issue_body_called_with_output_file(self, mock_evaluate): + def test_markdown_too_large_for_issue_body_called_with_output_file( + self, mock_evaluate + ): """ Test that the function uses the output_file. """ @@ -501,19 +494,13 @@ def test_markdown_too_large_for_issue_body_called_with_output_file(self, mock_ev mock_evaluate.assert_called_with("test_issue_metrics.md", 65535) - @patch.dict( - os.environ, - { - "GH_TOKEN": "test_token", - "SEARCH_QUERY": "is:issue is:open repo:user/repo", - "OUTPUT_FILE": "test_issue_metrics.md" - } - ) @patch("issue_metrics.print") @patch("shutil.move") @patch("issue_metrics.split_markdown_file") @patch("issue_metrics.markdown_too_large_for_issue_body") - def test_split_markdown_file_when_file_size_too_large(self, mock_evaluate, mock_split, mock_move, mock_print): + def test_split_markdown_file_when_file_size_too_large( + self, mock_evaluate, mock_split, mock_move, mock_print + ): """ Test that the function is called with the output_file environment variable. @@ -522,16 +509,18 @@ def test_split_markdown_file_when_file_size_too_large(self, mock_evaluate, mock_ evaluate_markdown_file_size("test_issue_metrics.md") mock_split.assert_called_with("test_issue_metrics.md", 65535) - mock_move.assert_has_calls([ - call("test_issue_metrics.md", "test_issue_metrics_full.md"), - call("test_issue_metrics_0.md", "test_issue_metrics.md") - ]) + mock_move.assert_has_calls( + [ + call("test_issue_metrics.md", "test_issue_metrics_full.md"), + call("test_issue_metrics_0.md", "test_issue_metrics.md"), + ] + ) mock_print.assert_called_with( "Issue metrics markdown file is too large for GitHub issue body and has been \ split into multiple files. ie. test_issue_metrics.md, test_issue_metrics_1.md, etc. \ The full file is saved as test_issue_metrics_full.md\n\ See https://github.com/github/issue-metrics/blob/main/docs/dealing-with-large-issue-metrics.md" - ) + ) if __name__ == "__main__":