Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linting fixes #116

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test_time_to_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
11 changes: 6 additions & 5 deletions test_time_to_ready_for_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand All @@ -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)
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions time_to_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions time_to_ready_for_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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