@@ -57,12 +57,18 @@ def __init__(
5757
5858 # --- github model ---
5959 self ._git_repository : GHRepo = client .get_repo (repository_name_or_id )
60- self ._git_pull_request : GHPullRequest = self ._git_repository .get_pull (pull_request_number )
60+ self ._git_pull_request : GHPullRequest = self ._git_repository .get_pull (
61+ pull_request_number
62+ )
6163
6264 # --- codedog model ---
6365 self ._repository : Repository = self ._build_repository (self ._git_repository )
64- self ._source_repository : Repository = self ._build_repository (self ._git_pull_request .base .repo )
65- self ._pull_request : PullRequest = self ._build_pull_request (self ._git_pull_request )
66+ self ._source_repository : Repository = self ._build_repository (
67+ self ._git_pull_request .base .repo
68+ )
69+ self ._pull_request : PullRequest = self ._build_pull_request (
70+ self ._git_pull_request
71+ )
6672
6773 @property
6874 def retriever_type (self ) -> str :
@@ -110,7 +116,7 @@ def _build_pull_request(self, git_pr: GHPullRequest) -> PullRequest:
110116 repository_id = git_pr .head .repo .id ,
111117 pull_request_number = git_pr .number ,
112118 title = git_pr .title ,
113- body = git_pr .body if git_pr is not None else "" ,
119+ body = git_pr .body if git_pr . body is not None else "" ,
114120 url = git_pr .html_url ,
115121 repository_name = git_pr .head .repo .full_name ,
116122 related_issues = related_issues ,
@@ -125,12 +131,19 @@ def _parse_and_build_related_issues(self, git_pr: GHPullRequest) -> list[Issue]:
125131 body = git_pr .body
126132
127133 issue_numbers = self ._parse_issue_numbers (title , body )
128- return [self ._get_and_build_issue (issue_number ) for issue_number in issue_numbers ]
134+ return [
135+ self ._get_and_build_issue (issue_number ) for issue_number in issue_numbers
136+ ]
129137
130138 def _parse_issue_numbers (self , title , body ) -> list [int ]:
131139 body_matches = re .finditer (GithubRetriever .ISSUE_PATTERN , body ) if body else []
132- title_matches = re .finditer (GithubRetriever .ISSUE_PATTERN , title ) if title else []
133- issue_numbers = [int (match .group (0 ).lstrip ("#" )) for match in itertools .chain (body_matches , title_matches )]
140+ title_matches = (
141+ re .finditer (GithubRetriever .ISSUE_PATTERN , title ) if title else []
142+ )
143+ issue_numbers = [
144+ int (match .group (0 ).lstrip ("#" ))
145+ for match in itertools .chain (body_matches , title_matches )
146+ ]
134147 return issue_numbers
135148
136149 def _get_and_build_issue (self , issue_number ):
@@ -141,7 +154,7 @@ def _build_issue(self, git_issue: GithubIssue) -> Issue:
141154 return Issue (
142155 issue_id = git_issue .number ,
143156 title = git_issue .title ,
144- description = git_issue .body ,
157+ description = git_issue .body if git_issue . body else "" ,
145158 url = git_issue .html_url ,
146159 _raw = git_issue ,
147160 )
@@ -153,11 +166,15 @@ def _build_change_file_list(self, git_pr: GHPullRequest) -> list[ChangeFile]:
153166 change_files .append (change_file )
154167 return change_files
155168
156- def _build_change_file (self , git_file : GithubFile , git_pr : GHPullRequest ) -> ChangeFile :
169+ def _build_change_file (
170+ self , git_file : GithubFile , git_pr : GHPullRequest
171+ ) -> ChangeFile :
157172 full_name = git_file .filename
158173 name = full_name .split ("/" )[- 1 ]
159174 suffix = name .split ("." )[- 1 ]
160- source_full_name = git_file .previous_filename if git_file .previous_filename else full_name
175+ source_full_name = (
176+ git_file .previous_filename if git_file .previous_filename else full_name
177+ )
161178
162179 return ChangeFile (
163180 blob_id = int (git_file .sha , 16 ),
@@ -179,7 +196,9 @@ def _build_change_file(self, git_file: GithubFile, git_pr: GHPullRequest) -> Cha
179196 def _convert_status (self , git_status : str ) -> ChangeStatus :
180197 return ChangeStatus (GithubRetriever .GITHUB_STATUS_MAPPING .get (git_status , "X" ))
181198
182- def _build_change_file_diff_url (self , git_file : GithubFile , git_pr : GHPullRequest ) -> str :
199+ def _build_change_file_diff_url (
200+ self , git_file : GithubFile , git_pr : GHPullRequest
201+ ) -> str :
183202 return f"{ git_pr .html_url } /files#diff-{ git_file .sha } "
184203
185204 def _parse_and_build_diff_content (self , git_file : GithubFile ) -> DiffContent :
@@ -195,7 +214,11 @@ def _parse_and_build_diff_content(self, git_file: GithubFile) -> DiffContent:
195214 )
196215
197216 def _build_patched_file (self , git_file : GithubFile ) -> PatchedFile :
198- prev_name = git_file .previous_filename if git_file .previous_filename else git_file .filename
217+ prev_name = (
218+ git_file .previous_filename
219+ if git_file .previous_filename
220+ else git_file .filename
221+ )
199222 return parse_patch_file (git_file .patch , prev_name , git_file .filename )
200223
201224 def _build_patched_file_segs (self , patched_file : PatchedFile ) -> list [DiffSegment ]:
0 commit comments