diff --git a/src/managers/issue_manager.py b/src/managers/issue_manager.py index 74938a7..db498bd 100644 --- a/src/managers/issue_manager.py +++ b/src/managers/issue_manager.py @@ -83,7 +83,9 @@ def handle_task_list(event: IssuesEvent) -> Optional[IssueJob]: continue # issue created in a previous run if created_issue := created_issues.get(task): - JobService.update(created_issue, checked=checked, job_status=JobStatus.PENDING) + JobService.update( + created_issue, checked=checked, job_status=JobStatus.PENDING + ) else: jobs.append( Job( @@ -103,7 +105,9 @@ def handle_task_list(event: IssuesEvent) -> Optional[IssueJob]: @lru_cache -def _cached_get_auth(hook_installation_target_id: int, installation_id: int) -> github.Auth: +def _cached_get_auth( + hook_installation_target_id: int, installation_id: int +) -> github.Auth: """Get the auth for the given installation, cached.""" return _get_auth(hook_installation_target_id, installation_id) @@ -111,7 +115,9 @@ def _cached_get_auth(hook_installation_target_id: int, installation_id: int) -> @lru_cache def _get_gh(hook_installation_target_id: int, installation_id: int) -> github.Github: """Get the Github object for the given installation, cached""" - return github.Github(auth=_cached_get_auth(hook_installation_target_id, installation_id)) + return github.Github( + auth=_cached_get_auth(hook_installation_target_id, installation_id) + ) @lru_cache @@ -143,7 +149,9 @@ def _get_repository(issue_job: IssueJob, repository_name: str) -> Repository: @lru_cache -def _instantiate_github_class(clazz: type[T], hook_installation_target_id: int, installation_id: int, url: str) -> T: +def _instantiate_github_class( + clazz: type[T], hook_installation_target_id: int, installation_id: int, url: str +) -> T: """Instantiate a Github class, cached""" return clazz( requester=_get_requester(hook_installation_target_id, installation_id), @@ -206,7 +214,9 @@ def _get_repository_url_and_title(issue_job: IssueJob, task: str) -> tuple[str, def process_pending_jobs(issue_job: IssueJob) -> NoReturn: """Process the pending jobs separating what is a job to create an issue from a job to update an issue""" - for job in JobService.filter(original_issue_url=issue_job.issue_url, job_status=JobStatus.PENDING): + for job in JobService.filter( + original_issue_url=issue_job.issue_url, job_status=JobStatus.PENDING + ): task = job.task if job.issue_ref or is_issue_ref(task): issue_ref = job.issue_ref or task @@ -234,7 +244,9 @@ def process_pending_jobs(issue_job: IssueJob) -> NoReturn: def process_update_issue_status(issue_job: IssueJob) -> NoReturn: """Process the update issue status jobs.""" - for job in JobService.filter(original_issue_url=issue_job.issue_url, job_status=JobStatus.UPDATE_ISSUE_STATUS): + for job in JobService.filter( + original_issue_url=issue_job.issue_url, job_status=JobStatus.UPDATE_ISSUE_STATUS + ): issue = _instantiate_github_class( Issue, issue_job.hook_installation_target_id, @@ -264,7 +276,9 @@ def _handle_checkbox(issue: Issue, checked: bool) -> NoReturn: def process_create_issue(issue_job: IssueJob) -> NoReturn: """Process the create_issue status jobs.""" - for job in JobService.filter(original_issue_url=issue_job.issue_url, job_status=JobStatus.CREATE_ISSUE): + for job in JobService.filter( + original_issue_url=issue_job.issue_url, job_status=JobStatus.CREATE_ISSUE + ): if created_issue := _create_issue(issue_job, job): JobService.update( job, @@ -334,9 +348,15 @@ def process_update_progress(issue_job: IssueJob) -> NoReturn: if issue_job.issue_job_status == IssueJobStatus.DONE: comment = "Job's done" else: - done = len(JobService.filter(original_issue_url=issue_job.issue_url, job_status=JobStatus.DONE)) + done = len( + JobService.filter( + original_issue_url=issue_job.issue_url, job_status=JobStatus.DONE + ) + ) total = len(JobService.filter(original_issue_url=issue_job.issue_url)) - comment = f"Analyzing the tasklist [{done}/{total}]\n{markdown_progress(done, total)}" + comment = ( + f"Analyzing the tasklist [{done}/{total}]\n{markdown_progress(done, total)}" + ) issue = _instantiate_github_class( Issue, issue_job.hook_installation_target_id,