@@ -77,7 +77,7 @@ def _update_attributes(self, issue):
77
77
#: Issue number (e.g. #15)
78
78
self .number = issue .get ('number' )
79
79
#: Dictionary URLs for the pull request (if they exist)
80
- self .pull_request = issue .get ('pull_request' )
80
+ self .pull_request_urls = issue .get ('pull_request' , {} )
81
81
m = match ('https?://[\w\d\-\.\:]+/(\S+)/(\S+)/(?:issues|pull)/\d+' ,
82
82
self .html_url )
83
83
#: Returns ('owner', 'repository') this issue was filed on.
@@ -242,6 +242,18 @@ def labels(self, number=-1, etag=None):
242
242
url = self ._build_url ('labels' , base_url = self ._api )
243
243
return self ._iter (int (number ), url , Label , etag = etag )
244
244
245
+ def pull_request (self ):
246
+ """Retrieve the pull request associated with this issue.
247
+
248
+ :returns: :class:`~github3.pulls.PullRequest`
249
+ """
250
+ from .. import pulls
251
+ json = None
252
+ pull_request_url = self .pull_request_urls .get ('url' )
253
+ if pull_request_url :
254
+ json = self ._json (self ._get (pull_request_url ), 200 )
255
+ return self ._instance_or_null (pulls .PullRequest , json )
256
+
245
257
@requires_auth
246
258
def remove_label (self , name ):
247
259
"""Removes label ``name`` from this issue.
0 commit comments