@@ -69,15 +69,14 @@ def validate_maintainers(repo, github_token):
6969 # Properly load nested teams.
7070 'Accept' : 'application/vnd.github.hellcat-preview+json' ,
7171 }))
72- for user in json .loads (response .read ()):
73- assignable .append (user ['login' ])
72+ assignable .extend (user ['login' ] for user in json .load (response ))
7473 # 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 )
7778 if matches is not None :
7879 url = matches .group (1 )
79- else :
80- url = None
8180
8281 errors = False
8382 for tool , maintainers in MAINTAINERS .items ():
@@ -251,13 +250,14 @@ def update_latest(
251250
252251
253252if __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 :
258257 validate_maintainers (repo , github_token )
259258 else :
260259 print ('skipping toolstate maintainers validation since no GitHub token is present' )
260+ # When validating maintainers don't run the full script.
261261 exit (0 )
262262
263263 cur_commit = sys .argv [1 ]
0 commit comments