Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with Black, isort and Ruff Formatter #250

Merged
merged 3 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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