11"""Command-line interface."""
22import logging
33import sys
4+ from typing import Any
5+ from typing import List
46from typing import Optional
7+ from typing import Set
58from typing import Union
69
710import github
@@ -30,7 +33,7 @@ def __init__(self) -> None:
3033 self .config_ini ()
3134
3235 def create_issues (
33- self , issue : Optional [prompt .Issue ] = None , github_repo = ""
36+ self , issue : Optional [prompt .Issue ] = None , github_repo : str = ""
3437 ) -> None :
3538 """Create issues."""
3639 if not issue :
@@ -45,7 +48,9 @@ def create_issues(
4548 for github_repo in self .configs .github_selected_repos :
4649 self ._create_issue_from_repo (github_repo , issue , labels )
4750
48- def _create_issue_from_repo (self , github_repo , issue , labels ):
51+ def _create_issue_from_repo (
52+ self , github_repo : str , issue : Any , labels : List [str ]
53+ ) -> None :
4954 """Create issue from one repository."""
5055 repo = self .github_connection .get_repo (github_repo )
5156 try :
@@ -63,7 +68,7 @@ def _create_issue_from_repo(self, github_repo, issue, labels):
6368 print (f"{ github_repo } : { github_exception .data ['message' ]} ." )
6469
6570 def create_pull_requests (
66- self , pr : Optional [prompt .PullRequest ] = None , github_repo = ""
71+ self , pr : Optional [prompt .PullRequest ] = None , github_repo : str = ""
6772 ) -> None :
6873 """Create pull requests."""
6974 if not pr :
@@ -75,7 +80,7 @@ def create_pull_requests(
7580 for github_repo in self .configs .github_selected_repos :
7681 self ._create_pull_request_from_repo (github_repo , pr )
7782
78- def _create_pull_request_from_repo (self , github_repo , pr ) :
83+ def _create_pull_request_from_repo (self , github_repo : str , pr : Any ) -> None :
7984 """Create pull request from one repository."""
8085 repo = self .github_connection .get_repo (github_repo )
8186 body = pr .body
@@ -96,12 +101,12 @@ def _create_pull_request_from_repo(self, github_repo, pr):
96101 extra = ""
97102 for error in github_exception .data ["errors" ]:
98103 if "message" in error :
99- extra += f"{ error ['message' ]} "
104+ extra += f"{ error ['message' ]} " # type: ignore
100105 else :
101- extra += f"Invalid field { error ['field' ]} . "
106+ extra += f"Invalid field { error ['field' ]} . " # type: ignore
102107 print (f"{ github_repo } : { github_exception .data ['message' ]} . { extra } " )
103108
104- def _link_issues (self , body , labels , pr , repo ) :
109+ def _link_issues (self , body : str , labels : Set [ Any ] , pr : Any , repo : Any ) -> Any :
105110 """Return body message linking issues."""
106111 issues = repo .get_issues (state = "open" )
107112 closes = ""
@@ -117,7 +122,7 @@ def _link_issues(self, body, labels, pr, repo):
117122 return body
118123
119124 def merge_pull_requests (
120- self , pr_merge : Optional [prompt .PullRequestMerge ] = None , github_repo = ""
125+ self , pr_merge : Optional [prompt .PullRequestMerge ] = None , github_repo : str = ""
121126 ) -> None :
122127 """Merge pull requests."""
123128 if not pr_merge :
@@ -136,7 +141,9 @@ def merge_pull_requests(
136141 for github_repo in self .configs .github_selected_repos :
137142 self ._merge_pull_request_from_repo (github_repo , head , pr_merge , state )
138143
139- def _merge_pull_request_from_repo (self , github_repo , head , pr_merge , state ):
144+ def _merge_pull_request_from_repo (
145+ self , github_repo : str , head : str , pr_merge : Any , state : str
146+ ) -> None :
140147 """Merge pull request from one repository."""
141148 repo = self .github_connection .get_repo (github_repo )
142149 pulls = repo .get_pulls (state = state , base = pr_merge .base , head = head )
@@ -165,7 +172,7 @@ def _merge_pull_request_from_repo(self, github_repo, head, pr_merge, state):
165172 )
166173 )
167174
168- def delete_branches (self , branch = "" , github_repo = "" ) -> None :
175+ def delete_branches (self , branch : str = "" , github_repo : str = "" ) -> None :
169176 """Delete branches."""
170177 if not branch :
171178 branch = prompt .delete_branches (self .configs .github_selected_repos )
@@ -176,7 +183,7 @@ def delete_branches(self, branch="", github_repo="") -> None:
176183 for github_repo in self .configs .github_selected_repos :
177184 self ._delete_branch_from_repo (github_repo , branch )
178185
179- def _delete_branch_from_repo (self , github_repo , branch ) :
186+ def _delete_branch_from_repo (self , github_repo : str , branch : str ) -> None :
180187 """Delete a branch from one repository."""
181188 repo = self .github_connection .get_repo (github_repo )
182189 try :
@@ -216,7 +223,7 @@ def get_github_repos(
216223 user : Union [
217224 github .AuthenticatedUser .AuthenticatedUser , github .NamedUser .NamedUser
218225 ],
219- ) -> github .PaginatedList .PaginatedList :
226+ ) -> github .PaginatedList .PaginatedList [ Any ] :
220227 """Get Github repos from user."""
221228 return user .get_repos ()
222229
0 commit comments