Skip to content

Commit

Permalink
style: format code with Black, isort and Ruff Formatter
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 352e660 according to the output
from Black, isort and Ruff Formatter.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored May 20, 2024
1 parent 352e660 commit 33da1e4
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions src/managers/issue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -103,15 +105,19 @@ 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)


@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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 33da1e4

Please sign in to comment.