@@ -39,14 +39,14 @@ class CheckPullRequest(models.GitHubCore):
39
39
"""
40
40
41
41
def _update_attributes (self , pull ):
42
- self .id = pull ['id' ]
43
- self .number = pull [' number' ]
44
- self .base = pull [' base' ]
45
- self .head = pull [' head' ]
46
- self ._api = self .url = pull [' url' ]
42
+ self .id = pull ["id" ]
43
+ self .number = pull [" number" ]
44
+ self .base = pull [" base" ]
45
+ self .head = pull [" head" ]
46
+ self ._api = self .url = pull [" url" ]
47
47
48
48
def _repr (self ):
49
- return ' <CheckPullRequest [#{0}]>' .format (self .number )
49
+ return " <CheckPullRequest [#{0}]>" .format (self .number )
50
50
51
51
def to_pull (self ):
52
52
"""Retrieve a full PullRequest object for this CheckPullRequest.
@@ -57,6 +57,7 @@ def to_pull(self):
57
57
:class:`~github3.pulls.PullRequest`
58
58
"""
59
59
from . import pulls
60
+
60
61
json = self ._json (self ._get (self .url ), 200 )
61
62
return self ._instance_or_null (pulls .PullRequest , json )
62
63
@@ -103,16 +104,17 @@ class CheckApp(models.GitHubCore):
103
104
"""
104
105
105
106
def _update_attributes (self , app ):
106
- self .description = app [' description' ]
107
- self .external_url = app [' external_url' ]
108
- self .html_url = app [' html_url' ]
109
- self .id = app ['id' ]
110
- self .name = app [' name' ]
111
- self .owner = app [' owner' ]
107
+ self .description = app [" description" ]
108
+ self .external_url = app [" external_url" ]
109
+ self .html_url = app [" html_url" ]
110
+ self .id = app ["id" ]
111
+ self .name = app [" name" ]
112
+ self .owner = app [" owner" ]
112
113
113
114
def _repr (self ):
114
- return '<App ["{}" by {}]>' .format (self .name ,
115
- str (self .owner ['login' ]))
115
+ return '<App ["{}" by {}]>' .format (
116
+ self .name , str (self .owner ["login" ])
117
+ )
116
118
117
119
def to_app (self ):
118
120
"""Retrieve a full App object for this CheckApp.
@@ -123,6 +125,7 @@ def to_app(self):
123
125
:class:`~github3.apps.App`
124
126
"""
125
127
from . import apps
128
+
126
129
json = self ._json (self ._get (self .url ), 200 )
127
130
return self ._instance_or_null (apps .App , json )
128
131
@@ -189,31 +192,30 @@ class CheckSuite(models.GitHubCore):
189
192
http://developer.github.com/v3/checks/suites/
190
193
"""
191
194
192
- class_name = 'CheckSuite'
193
- CUSTOM_HEADERS = {
194
- 'Accept' : 'application/vnd.github.antiope-preview+json'
195
- }
195
+ class_name = "CheckSuite"
196
+ CUSTOM_HEADERS = {"Accept" : "application/vnd.github.antiope-preview+json" }
196
197
197
198
def _update_attributes (self , suite ):
198
199
# Import here, because a toplevel import causes an import loop
199
200
from . import repos
200
- self ._api = suite ['url' ]
201
- self .status = suite ['status' ]
202
- self .conclusion = suite ['conclusion' ]
203
- self .head_branch = suite ['head_branch' ]
204
- self .head_sha = suite ['head_sha' ]
205
- self .before = suite ['before' ]
206
- self .after = suite ['after' ]
207
- prs = suite .get ('pull_requests' , [])
201
+
202
+ self ._api = suite ["url" ]
203
+ self .status = suite ["status" ]
204
+ self .conclusion = suite ["conclusion" ]
205
+ self .head_branch = suite ["head_branch" ]
206
+ self .head_sha = suite ["head_sha" ]
207
+ self .before = suite ["before" ]
208
+ self .after = suite ["after" ]
209
+ prs = suite .get ("pull_requests" , [])
208
210
self .origional_pull_requests = [
209
211
CheckPullRequest (p , self ) for p in prs
210
212
]
211
- self .repository = repos .ShortRepository (suite [' repository' ], self )
212
- self .id = suite ['id' ]
213
- self .app = CheckApp (suite [' app' ], self )
213
+ self .repository = repos .ShortRepository (suite [" repository" ], self )
214
+ self .id = suite ["id" ]
215
+ self .app = CheckApp (suite [" app" ], self )
214
216
215
217
def _repr (self ):
216
- return ' <{s.class_name} [{s.id}:{s.status}]>' .format (s = self )
218
+ return " <{s.class_name} [{s.id}:{s.status}]>" .format (s = self )
217
219
218
220
@decorators .requires_app_installation_auth
219
221
def rerequest (self ):
@@ -224,9 +226,10 @@ def rerequest(self):
224
226
:rtype:
225
227
bool
226
228
"""
227
- url = self ._build_url ('rerequest' , base_url = self ._api )
228
- return self ._boolean (self ._post (
229
- url , headers = CheckSuite .CUSTOM_HEADERS ), 201 , 404 )
229
+ url = self ._build_url ("rerequest" , base_url = self ._api )
230
+ return self ._boolean (
231
+ self ._post (url , headers = CheckSuite .CUSTOM_HEADERS ), 201 , 404
232
+ )
230
233
231
234
@decorators .requires_app_installation_auth
232
235
def check_runs (self ):
@@ -237,9 +240,10 @@ def check_runs(self):
237
240
:rtype:
238
241
:class:`~github3.checks.CheckRun`
239
242
"""
240
- url = self ._build_url ('check-runs' , base_url = self ._api )
241
- return self ._iter (- 1 , url , CheckRun ,
242
- headers = CheckSuite .CUSTOM_HEADERS )
243
+ url = self ._build_url ("check-runs" , base_url = self ._api )
244
+ return self ._iter (
245
+ - 1 , url , CheckRun , headers = CheckSuite .CUSTOM_HEADERS
246
+ )
243
247
244
248
245
249
class CheckRun (models .GitHubCore ):
@@ -317,38 +321,45 @@ class CheckRun(models.GitHubCore):
317
321
http://developer.github.com/v3/checks/runs/
318
322
"""
319
323
320
- class_name = 'CheckRun'
321
- CUSTOM_HEADERS = {
322
- 'Accept' : 'application/vnd.github.antiope-preview+json'
323
- }
324
+ class_name = "CheckRun"
325
+ CUSTOM_HEADERS = {"Accept" : "application/vnd.github.antiope-preview+json" }
324
326
325
327
def _update_attributes (self , run ):
326
- self ._api = run [' url' ]
327
- self .html_url = run [' html_url' ]
328
- self .status = run [' status' ]
329
- self .conclusion = run [' conclusion' ]
330
- self .started_at = self ._strptime (run [' started_at' ])
331
- self .completed_at = self ._strptime (run [' completed_at' ])
332
- self .head_sha = run [' head_sha' ]
333
- self .name = run [' name' ]
334
- prs = run .get (' pull_requests' , [])
328
+ self ._api = run [" url" ]
329
+ self .html_url = run [" html_url" ]
330
+ self .status = run [" status" ]
331
+ self .conclusion = run [" conclusion" ]
332
+ self .started_at = self ._strptime (run [" started_at" ])
333
+ self .completed_at = self ._strptime (run [" completed_at" ])
334
+ self .head_sha = run [" head_sha" ]
335
+ self .name = run [" name" ]
336
+ prs = run .get (" pull_requests" , [])
335
337
self .origional_pull_requests = [
336
338
CheckPullRequest (p , self ) for p in prs
337
339
]
338
- self .id = run ['id' ]
339
- self .external_id = run [' external_id' ]
340
- self .app = CheckApp (run [' app' ], self )
341
- self .check_suite = run [' check_suite' ][ 'id' ]
340
+ self .id = run ["id" ]
341
+ self .external_id = run [" external_id" ]
342
+ self .app = CheckApp (run [" app" ], self )
343
+ self .check_suite = run [" check_suite" ][ "id" ]
342
344
# self.output = CheckRunOutput(run['output'], self)
343
- self .output = run [' output' ] # TODO: turn into an object
345
+ self .output = run [" output" ] # TODO: turn into an object
344
346
345
347
def _repr (self ):
346
- return ' <{s.class_name} [{s.name}:{s.status}]>' .format (s = self )
348
+ return " <{s.class_name} [{s.name}:{s.status}]>" .format (s = self )
347
349
348
350
@decorators .requires_app_installation_auth
349
- def update (self , name = None , details_url = None , external_id = None ,
350
- started_at = None , status = None , conclusion = None ,
351
- completed_at = None , output = None , actions = None ):
351
+ def update (
352
+ self ,
353
+ name = None ,
354
+ details_url = None ,
355
+ external_id = None ,
356
+ started_at = None ,
357
+ status = None ,
358
+ conclusion = None ,
359
+ completed_at = None ,
360
+ output = None ,
361
+ actions = None ,
362
+ ):
352
363
"""Update this check run.
353
364
354
365
All parameters are optional.
@@ -385,17 +396,28 @@ def update(self, name=None, details_url=None, external_id=None,
385
396
bool
386
397
"""
387
398
# TODO: Clean output dict, actions array. Need a deep recursive clean
388
- data = {'name' : name , 'details_url' : details_url , 'external_id' :
389
- external_id , 'started_at' : started_at , 'status' : status ,
390
- 'conclusion' : conclusion , 'completed_at' : completed_at ,
391
- 'output' : output , 'actions' : actions }
399
+ data = {
400
+ "name" : name ,
401
+ "details_url" : details_url ,
402
+ "external_id" : external_id ,
403
+ "started_at" : started_at ,
404
+ "status" : status ,
405
+ "conclusion" : conclusion ,
406
+ "completed_at" : completed_at ,
407
+ "output" : output ,
408
+ "actions" : actions ,
409
+ }
392
410
self ._remove_none (data )
393
411
json = None
394
412
395
413
if data :
396
- json = self ._json (self ._patch (
397
- self ._api , data = dumps (data ),
398
- headers = CheckSuite .CUSTOM_HEADERS ), 200
414
+ json = self ._json (
415
+ self ._patch (
416
+ self ._api ,
417
+ data = dumps (data ),
418
+ headers = CheckSuite .CUSTOM_HEADERS ,
419
+ ),
420
+ 200 ,
399
421
)
400
422
if json :
401
423
self ._update_attributes (json )
@@ -411,6 +433,7 @@ def rerequest(self):
411
433
:rtype:
412
434
bool
413
435
"""
414
- url = self ._build_url ('rerequest' , base_url = self ._api )
415
- return self ._boolean (self ._post (
416
- url , headers = CheckSuite .CUSTOM_HEADERS ), 201 , 404 )
436
+ url = self ._build_url ("rerequest" , base_url = self ._api )
437
+ return self ._boolean (
438
+ self ._post (url , headers = CheckSuite .CUSTOM_HEADERS ), 201 , 404
439
+ )
0 commit comments