Maciej Szulik added the comment:

@anish.shah

roundup/github_pullrequest_url.py

> def __init__(self, client):
> ....
>     self._validate_webhook_secret()
>     self._verify_request()
>     self._extract()

Don't put the entire action in the constructor of the object. Its 
responsibility is to create an object
and then you call actions on it. Here dispatch is the method you should create 
that should do what you want here.

>  result = compare_digest(signature, header_signature)
>        if not result:

Replace with:

if not compare_digest(signature, header_signature):

reads better.

> def _get_event(self):
>     event = self.request.headers.get('X-GitHub-Event', None)
>     return event

Replace with:

def _get_event(self):
    return self.request.headers.get('X-GitHub-Event', None)

> if event == 'pull_request':
>     PullRequest(self.db, self.data)
> elif event == 'issue_comment':
>     IssueComment(self.db, self.data)

Same here. Create objects and act upon them, don't run actions inside the 
initialization. 

I'll get back to this patch once again tomorrow.

_______________________________________________________
PSF Meta Tracker <metatrac...@psf.upfronthosting.co.za>
<http://psf.upfronthosting.co.za/roundup/meta/issue589>
_______________________________________________________
_______________________________________________
Tracker-discuss mailing list
Tracker-discuss@python.org
https://mail.python.org/mailman/listinfo/tracker-discuss
Code of Conduct: https://www.python.org/psf/codeofconduct/

Reply via email to