Skip to content

validate bpo number - #72

Closed
levlaz wants to merge 3 commits into
python:masterfrom
levlaz:validate_bpo_exists
Closed

levlaz wants to merge 3 commits into
python:masterfrom
levlaz:validate_bpo_exists

Conversation

@levlaz

@levlaz levlaz commented Nov 9, 2017

Copy link
Copy Markdown

Add helper function to check if the issue number exists on bpo.

set FAILURE_STATUS in the event that the issue does not exist.

Fix #15

Add helper function to check if the issue number exists on bpo.

set FAILURE_STATUS in the event that the issue does not exist.

Fix #15
@codecov

codecov Bot commented Nov 9, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #72 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #72   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          14     14           
  Lines         923    953   +30     
  Branches       55     56    +1     
=====================================
+ Hits          923    953   +30
Impacted Files Coverage Δ
tests/test_bpo.py 100% <100%> (ø) ⬆️
bedevere/bpo.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81f8490...154e963. Read the comment docs.

Comment thread bedevere/bpo.py
STATUS_CONTEXT = "bedevere/issue-number"
# Try to keep descriptions at or below 50 characters, else GitHub's CSS will truncate it.
_FAILURE_DESCRIPTION = 'No issue # in title or "skip issue" label found'
_FAILURE_DESCRIPTION = 'Issue does not exit, No issue # in title or "skip issue" label found'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This felt a little dirty, but I was not sure if we wanted to "yet another" edge case of failure description. Happy to refactor this if we want to be more specific of the reason for failure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this might be too long as a status check message.
I'm thinking it can be a separate status check, maybe "bedevere/valid-issue"? @brettcannon, what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need another status check (we are already at 4). Is there any reason the message can't be dynamically specified like for the NEWS.d check? In this instance the current message is the one that shows up if anything is found, but if an issue number is discovered but found not to exist, a different message saying something like "issue #NNNN not found at bugs.python.org" or something would be set while still flagging a status check failure.

Make sense?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a different message sounds good :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrections to message: /exit/exist/, /No/no/, /title/title,/. But +1 to situation specific message. This is not an exception raised in inner loops for control flow. (The reason for some quick and vague exception messages.)

Comment thread tests/test_bpo.py Outdated
assert gh.patch_url is None


def test_validate_issue_number():

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a "unit" test but it actually makes a call to bpo... maybe this should be mocked as well (or it may not be necessary all together).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference is to mock the call to b.p.o.

@Mariatta Mariatta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I have a few comments, mostly just nitpicky :)
I think the new failure description is a little too long. Perhaps it should be a separate status check?

Comment thread bedevere/bpo.py
STATUS_CONTEXT = "bedevere/issue-number"
# Try to keep descriptions at or below 50 characters, else GitHub's CSS will truncate it.
_FAILURE_DESCRIPTION = 'No issue # in title or "skip issue" label found'
_FAILURE_DESCRIPTION = 'Issue does not exit, No issue # in title or "skip issue" label found'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this might be too long as a status check message.
I'm thinking it can be a separate status check, maybe "bedevere/valid-issue"? @brettcannon, what do you think?

Comment thread bedevere/bpo.py Outdated
target_url=url)

def validate_issue_number(issue_number):
"""Validate that the issue number exists on bpo"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring should end with a period :)

Comment thread bedevere/bpo.py Outdated
urllib.request.urlopen(req)
return True
except urllib.error.HTTPError:
return False No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a newline.

Comment thread tests/test_bpo.py Outdated
assert gh.patch_url is None


def test_validate_issue_number():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference is to mock the call to b.p.o.

Comment thread bedevere/bpo.py Outdated
@@ -1,5 +1,7 @@
"""Check if a bugs.python.org issue number is specified in the pull request's title."""
import re
import urllib.request

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about from urllib import error, request instead?

@Mariatta
Mariatta requested a review from brettcannon November 10, 2017 03:56
@levlaz

levlaz commented Nov 12, 2017

Copy link
Copy Markdown
Author

Thank you for the review @Mariatta, I made all of the requested changes except for defining a new status check message since you want to get some feedback from Brett.

Happy to implement whatever you all decide.

@brettcannon brettcannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Let's go with different status check messages based on why the check failed. Otherwise a very minor tweak to a function name.

Comment thread bedevere/bpo.py
description=f"Issue number {issue_number} found",
target_url=url)

def validate_issue_number(issue_number):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start with an underscore since this shouldn't be used outside of this module.

Comment thread bedevere/bpo.py
url = f"https://bugs.python.org/issue{issue_number}"
req = request.Request(url=url, method='HEAD')
try:
res = request.urlopen(req)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t this use an async request instead of dear old urllib?

@Mariatta

Copy link
Copy Markdown
Member

@levlaz still working on this?

@lysnikolaou

lysnikolaou commented Mar 21, 2019 •

Copy link
Copy Markdown
Member

Since @levlaz is apparently no longer working on this, should this PR may be closed? @Mariatta?

@mariatta-bot

Copy link
Copy Markdown

Mariatta was mentioned, but she's out of open source from March 18th to May 9th, 2019 . Be aware she might not get to this until after PyCon US.
(I'm a bot)

@brettcannon

Copy link
Copy Markdown
Member

Due to this stalling out, I'm closing the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants