|
16 | 16 | import requests
|
17 | 17 | import sys
|
18 | 18 | import time
|
19 |
| -from typing import * |
| 19 | +from typing import List, Optional |
20 | 20 |
|
21 | 21 | class IssueSubscriber:
|
22 | 22 |
|
@@ -60,7 +60,7 @@ def phab_api_call(phab_token:str, url:str, args:dict) -> dict:
|
60 | 60 | return response.json()
|
61 | 61 |
|
62 | 62 |
|
63 |
| -def phab_login_to_github_login(phab_token:str, repo:github.Repository.Repository, phab_login:str) -> str: |
| 63 | +def phab_login_to_github_login(phab_token:str, repo:github.Repository.Repository, phab_login:str) -> Optional[str]: |
64 | 64 | """
|
65 | 65 | Tries to translate a Phabricator login to a github login by
|
66 | 66 | finding a commit made in Phabricator's Differential.
|
@@ -94,7 +94,7 @@ def phab_login_to_github_login(phab_token:str, repo:github.Repository.Repository
|
94 | 94 | return None
|
95 | 95 | return committer.login
|
96 | 96 |
|
97 |
| -def phab_get_commit_approvers(phab_token:str, repo:github.Repository.Repository, commit:github.Commit.Commit) -> list: |
| 97 | +def phab_get_commit_approvers(phab_token:str, commit:github.Commit.Commit) -> list: |
98 | 98 | args = { "corpus" : commit.commit.message }
|
99 | 99 | # API documentation: https://reviews.llvm.org/conduit/method/differential.parsecommitmessage/
|
100 | 100 | r = phab_api_call(phab_token, "https://reviews.llvm.org/api/differential.parsecommitmessage", args)
|
@@ -263,7 +263,7 @@ def pr_request_review(self, pr:github.PullRequest.PullRequest):
|
263 | 263 | """
|
264 | 264 | reviewers = []
|
265 | 265 | for commit in pr.get_commits():
|
266 |
| - approvers = phab_get_commit_approvers(self.phab_token, self.repo, commit) |
| 266 | + approvers = phab_get_commit_approvers(self.phab_token, commit) |
267 | 267 | for a in approvers:
|
268 | 268 | login = phab_login_to_github_login(self.phab_token, self.repo, a)
|
269 | 269 | if not login:
|
@@ -334,7 +334,7 @@ def create_pull_request(self, owner:str, repo_name:str, branch:str) -> bool:
|
334 | 334 | head_branch = f'{owner}-{branch}'
|
335 | 335 | local_repo = Repo(self.llvm_project_dir)
|
336 | 336 | push_done = False
|
337 |
| - for i in range(0,5): |
| 337 | + for _ in range(0,5): |
338 | 338 | try:
|
339 | 339 | local_repo.git.fetch(f'https://github.com/{owner}/{repo_name}', f'{branch}:{branch}')
|
340 | 340 | local_repo.git.push(self.push_url, f'{branch}:{head_branch}', force=True)
|
@@ -388,7 +388,7 @@ def execute_command(self) -> bool:
|
388 | 388 | """
|
389 | 389 | for line in sys.stdin:
|
390 | 390 | line.rstrip()
|
391 |
| - m = re.search("/([a-z-]+)\s(.+)", line) |
| 391 | + m = re.search(r"/([a-z-]+)\s(.+)", line) |
392 | 392 | if not m:
|
393 | 393 | continue
|
394 | 394 | command = m.group(1)
|
|
0 commit comments