@@ -69,15 +69,14 @@ def validate_maintainers(repo, github_token):
69
69
# Properly load nested teams.
70
70
'Accept' : 'application/vnd.github.hellcat-preview+json' ,
71
71
}))
72
- for user in json .loads (response .read ()):
73
- assignable .append (user ['login' ])
72
+ assignable .extend (user ['login' ] for user in json .load (response ))
74
73
# Load the next page if available
75
- if 'Link' in response .headers :
76
- matches = next_link_re .match (response .headers ['Link' ])
74
+ url = None
75
+ link_header = response .headers .get ('Link' )
76
+ if link_header :
77
+ matches = next_link_re .match (link_header )
77
78
if matches is not None :
78
79
url = matches .group (1 )
79
- else :
80
- url = None
81
80
82
81
errors = False
83
82
for tool , maintainers in MAINTAINERS .items ():
@@ -251,13 +250,14 @@ def update_latest(
251
250
252
251
253
252
if __name__ == '__main__' :
254
- if 'TOOLSTATE_VALIDATE_MAINTAINERS_REPO' in os .environ :
255
- repo = os . environ [ 'TOOLSTATE_VALIDATE_MAINTAINERS_REPO' ]
256
- if 'TOOLSTATE_REPO_ACCESS_TOKEN' in os .environ :
257
- github_token = os . environ [ 'TOOLSTATE_REPO_ACCESS_TOKEN' ]
253
+ repo = os .environ . get ( 'TOOLSTATE_VALIDATE_MAINTAINERS_REPO' )
254
+ if repo :
255
+ github_token = os .environ . get ( 'TOOLSTATE_REPO_ACCESS_TOKEN' )
256
+ if github_token :
258
257
validate_maintainers (repo , github_token )
259
258
else :
260
259
print ('skipping toolstate maintainers validation since no GitHub token is present' )
260
+ # When validating maintainers don't run the full script.
261
261
exit (0 )
262
262
263
263
cur_commit = sys .argv [1 ]
0 commit comments