diff --git a/test_time_to_merge.py b/test_time_to_merge.py index abe5e86..08fa496 100644 --- a/test_time_to_merge.py +++ b/test_time_to_merge.py @@ -14,6 +14,7 @@ from time_to_merge import measure_time_to_merge + class TestMeasureTimeToMerge(unittest.TestCase): """Test suite for the measure_time_to_merge function.""" diff --git a/test_time_to_ready_for_review.py b/test_time_to_ready_for_review.py index 16108ea..cd2b626 100644 --- a/test_time_to_ready_for_review.py +++ b/test_time_to_ready_for_review.py @@ -14,6 +14,7 @@ from time_to_ready_for_review import get_time_to_ready_for_review + class TestGetTimeToReadyForReview(unittest.TestCase): """Test suite for the get_time_to_ready_for_review function.""" @@ -33,11 +34,11 @@ def test_get_time_to_ready_for_review_event(self): pull_request = MagicMock() pull_request.draft = False event = MagicMock() - event.event = 'ready_for_review' + event.event = "ready_for_review" event.created_at = datetime.fromisoformat("2021-01-01T00:00:00Z") issue = MagicMock() - issue.issue.events.return_value=[event] - + issue.issue.events.return_value = [event] + result = get_time_to_ready_for_review(issue, pull_request) expected_result = event.created_at self.assertEqual(result, expected_result) @@ -47,10 +48,10 @@ def test_get_time_to_ready_for_review_no_event(self): pull_request = MagicMock() pull_request.draft = False event = MagicMock() - event.event = 'foobar' + event.event = "foobar" event.created_at = "2021-01-01T00:00:00Z" issue = MagicMock() - issue.events.return_value=[event] + issue.events.return_value = [event] result = get_time_to_ready_for_review(issue, pull_request) expected_result = None diff --git a/time_to_merge.py b/time_to_merge.py index dbf3d86..dbd4f2c 100644 --- a/time_to_merge.py +++ b/time_to_merge.py @@ -12,19 +12,19 @@ """ from datetime import datetime, timedelta -from typing import List, Union +from typing import Union import github3 + def measure_time_to_merge( - pull_request: github3.pulls.PullRequest, - ready_for_review_at: Union[datetime, None] + pull_request: github3.pulls.PullRequest, ready_for_review_at: Union[datetime, None] ) -> Union[timedelta, None]: """Measure the time it takes to merge a pull request. Args: pull_request (github3.pulls.PullRequest): A GitHub pull request. - ready_for_review_at (Union[timedelta, None]): When the PR was marked as ready for review + ready_for_review_at (Union[timedelta, None]): When the PR was marked as ready for review Returns: Union[datetime.timedelta, None]: The time it takes to close the issue. diff --git a/time_to_ready_for_review.py b/time_to_ready_for_review.py index ea8aa26..8c744b1 100644 --- a/time_to_ready_for_review.py +++ b/time_to_ready_for_review.py @@ -19,13 +19,13 @@ import github3 + def get_time_to_ready_for_review( - issue: github3.issues.Issue, - pull_request: github3.pulls.PullRequest + issue: github3.issues.Issue, pull_request: github3.pulls.PullRequest ) -> Union[datetime, None]: """If a pull request was formerly a draft, get the time it was marked as ready for review - + Args: issue (github3.issues.Issue): A GitHub issue. pull_request (github3.pulls.PullRequest): A GitHub pull request. @@ -38,7 +38,7 @@ def get_time_to_ready_for_review( events = issue.issue.events(number=50) for event in events: - if event.event == 'ready_for_review': + if event.event == "ready_for_review": return event.created_at return None