Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent a4701f4 commit 25ba508
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 106 deletions.
2 changes: 1 addition & 1 deletion alembic/versions/a5c06aa9ef30_add_runmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def upgrade():
for test, build in zip(test_group, matching_builds):
if len(build.runs) != 1:
PackitException(
f"Build {build} does not have exactly one run:\n" f"{build.runs}",
f"Build {build} does not have exactly one run:\n{build.runs}",
)
test_runs_attached += 1
build.runs[-1].test_run = test
Expand Down
2 changes: 1 addition & 1 deletion alembic/versions/a619bd414ff0_add_build_status_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def upgrade():
"ALTER COLUMN status TYPE buildstatus USING status::buildstatus",
)
op.execute(
"ALTER TABLE srpm_builds " "ALTER COLUMN status TYPE buildstatus USING status::buildstatus",
"ALTER TABLE srpm_builds ALTER COLUMN status TYPE buildstatus USING status::buildstatus",
)


Expand Down
2 changes: 1 addition & 1 deletion alembic/versions/c6250555a36c_.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def upgrade():

status = copr_build.get("status")
web_url = (
f"https://copr.fedorainfracloud.org/coprs/{owner}/{project_name}/" f"build/{build_id}/"
f"https://copr.fedorainfracloud.org/coprs/{owner}/{project_name}/build/{build_id}/"
)

try:
Expand Down
5 changes: 2 additions & 3 deletions packit_service/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@
NOTIFICATION_REPO = "https://github.com/packit/notifications"

PERMISSIONS_ERROR_WRITE_OR_ADMIN = (
"Only users with write or admin permissions to the repository "
"can trigger Packit-as-a-Service"
"Only users with write or admin permissions to the repository can trigger Packit-as-a-Service"
)

TASK_ACCEPTED = "The task was accepted."
Expand Down Expand Up @@ -137,7 +136,7 @@

CELERY_DEFAULT_MAIN_TASK_NAME = "task.steve_jobs.process_message"

MSG_TABLE_HEADER_WITH_DETAILS = "| Name/Job | URL |\n" "| --- | --- |\n"
MSG_TABLE_HEADER_WITH_DETAILS = "| Name/Job | URL |\n| --- | --- |\n"

DEFAULT_MAPPING_TF = {
"epel-6": "centos-6",
Expand Down
14 changes: 5 additions & 9 deletions packit_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,7 @@ def get_by_id(cls, id_: int) -> Optional["AnityaMultipleVersionsModel"]:
return session.query(AnityaVersionModel).filter_by(id=id_).first()

def __repr__(self):
return (
f"AnityaMultipleVersionsModel(" f"versions={self.versions}, " f"project={self.project})"
)
return f"AnityaMultipleVersionsModel(versions={self.versions}, project={self.project})"


class AnityaVersionModel(BuildsAndTestsConnector, Base):
Expand Down Expand Up @@ -593,7 +591,7 @@ def get_by_id(cls, id_: int) -> Optional["AnityaVersionModel"]:
return session.query(AnityaVersionModel).filter_by(id=id_).first()

def __repr__(self):
return f"AnityaVersionModel(" f"version={self.version}, " f"project={self.project})"
return f"AnityaVersionModel(version={self.version}, project={self.project})"


class GitProjectModel(Base):
Expand Down Expand Up @@ -1487,7 +1485,7 @@ def get_by_id(cls, id_: int) -> Optional["ProjectReleaseModel"]:
return session.query(ProjectReleaseModel).filter_by(id=id_).first()

def __repr__(self):
return f"ProjectReleaseModel(" f"tag_name={self.tag_name}, " f"project={self.project})"
return f"ProjectReleaseModel(tag_name={self.tag_name}, project={self.project})"


class KojiBuildTagModel(BuildsAndTestsConnector, Base):
Expand Down Expand Up @@ -2330,8 +2328,7 @@ def get(

def __repr__(self):
return (
f"CoprBuildTargetModel(id={self.id}, "
f"build_submitted_time={self.build_submitted_time})"
f"CoprBuildTargetModel(id={self.id}, build_submitted_time={self.build_submitted_time})"
)

def add_scan(self, task_id: int) -> "OSHScanModel":
Expand Down Expand Up @@ -2789,8 +2786,7 @@ def get(

def __repr__(self):
return (
f"KojiBuildTargetModel(id={self.id}, "
f"build_submitted_time={self.build_submitted_time})"
f"KojiBuildTargetModel(id={self.id}, build_submitted_time={self.build_submitted_time})"
)

@classmethod
Expand Down
3 changes: 1 addition & 2 deletions packit_service/worker/checker/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ def pre_check(self) -> bool:
valid = True
msg_to_report = None
issue_title = (
"Pull from upstream could not be run for update "
f"{self.data.event_dict.get('version')}"
f"Pull from upstream could not be run for update {self.data.event_dict.get('version')}"
)

if self.package_config.upstream_project_url and not (
Expand Down
3 changes: 1 addition & 2 deletions packit_service/worker/checker/forges.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def pre_check(self) -> bool:
"""
if not (self.project.namespace == "packit" and self.project.repo == "notifications"):
logger.debug(
"Packit verification comment command not placed"
"in packit/notifications repository.",
"Packit verification comment command not placedin packit/notifications repository.",
)
return False

Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def discard_old_srpm_build_logs():
ago = timedelta(days=int(outdated_after_days))
for build in SRPMBuildModel.get_older_than(ago):
logger.debug(
f"SRPM build {build.id} is older than '{ago}'. " "Discarding log and artifact url.",
f"SRPM build {build.id} is older than '{ago}'. Discarding log and artifact url.",
)
build.set_logs(None)
build.set_url(None)
Expand Down
3 changes: 1 addition & 2 deletions packit_service/worker/events/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ def _add_release_trigger(self):

if not release or release.git_tag.commit_sha != self.commit_sha:
logger.debug(
"Release with tag name from comment doesn't exist or doesn't match "
"the commit SHA.",
"Release with tag name from comment doesn't exist or doesn't match the commit SHA.",
)
return

Expand Down
3 changes: 1 addition & 2 deletions packit_service/worker/events/koji.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def get_koji_build_logs_url(
You can redefine the Koji instance using the one defined in the service config.
"""
return (
f"{koji_logs_url}//work/tasks/"
f"{rpm_build_task_id % 10000}/{rpm_build_task_id}/build.log"
f"{koji_logs_url}//work/tasks/{rpm_build_task_id % 10000}/{rpm_build_task_id}/build.log"
)

def get_koji_build_rpm_tasks_logs_urls(
Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/events/new_hotness.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def packages_config(self):
return self._package_config

def get_packages_config(self) -> Optional[PackageConfig]:
logger.debug(f"Getting package_config:\n" f"\tproject: {self.project}\n")
logger.debug(f"Getting package_config:\n\tproject: {self.project}\n")

return PackageConfigGetter.get_package_config_from_repo(
base_project=None,
Expand Down
9 changes: 4 additions & 5 deletions packit_service/worker/handlers/bodhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ def report_in_issue_repository(self, errors: dict[str, str]) -> None:
packit_comment_command_prefix=self.service_config.comment_command_prefix,
)
body_msg = (
f"{body}\n{self.get_trigger_type_description()}\n\n"
f"{msg_retrigger}{MSG_GET_IN_TOUCH}\n"
f"{body}\n{self.get_trigger_type_description()}\n\n{msg_retrigger}{MSG_GET_IN_TOUCH}\n"
)

body_msg = update_message_with_configured_failure_comment_message(
Expand Down Expand Up @@ -343,7 +342,7 @@ def get_checkers() -> tuple[type[Checker], ...]:

def get_trigger_type_description(self) -> str:
for koji_build_data in self:
return f"Fedora Bodhi update was triggered by " f"Koji build {koji_build_data.nvr}."
return f"Fedora Bodhi update was triggered by Koji build {koji_build_data.nvr}."
return ""

def _get_or_create_bodhi_update_group_model(self) -> BodhiUpdateGroupModel:
Expand Down Expand Up @@ -398,7 +397,7 @@ def get_checkers() -> tuple[type[Checker], ...]:

def get_trigger_type_description(self) -> str:
for koji_build_data in self:
return f"Fedora Bodhi update was triggered by " f"Koji build {koji_build_data.nvr}."
return f"Fedora Bodhi update was triggered by Koji build {koji_build_data.nvr}."
return ""


Expand Down Expand Up @@ -459,4 +458,4 @@ def get_checkers() -> tuple[type[Checker], ...]:
return (HasIssueCommenterRetriggeringPermissions,)

def get_trigger_type_description(self) -> str:
return f"Fedora Bodhi update was re-triggered by " f"comment in issue {self.data.issue_id}."
return f"Fedora Bodhi update was re-triggered by comment in issue {self.data.issue_id}."
2 changes: 1 addition & 1 deletion packit_service/worker/handlers/copr.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def run(self):
return TaskResults(success=False, details={"msg": msg})

if self.build.build_start_time is not None:
msg = f"Copr build start for {self.copr_event.build_id} is already" f" processed."
msg = f"Copr build start for {self.copr_event.build_id} is already processed."
logger.debug(msg)
return TaskResults(success=True, details={"msg": msg})

Expand Down
11 changes: 5 additions & 6 deletions packit_service/worker/handlers/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def run_for_target(
)
self.sync_release_helper.report_status_for_branch(
branch=branch,
description=f"{self.job_name_for_reporting.capitalize()} " f"finished successfully.",
description=f"{self.job_name_for_reporting.capitalize()} finished successfully.",
state=BaseCommitStatus.success,
url=url,
)
Expand Down Expand Up @@ -632,7 +632,7 @@ def _report_errors_for_each_branch(self, message: str) -> None:

PackageConfigGetter.create_issue_if_needed(
project=self.project,
title=f"{self.job_name_for_reporting.capitalize()} failed for " f"release {self.tag}",
title=f"{self.job_name_for_reporting.capitalize()} failed for release {self.tag}",
message=body_msg,
comment_to_existing=body_msg,
)
Expand Down Expand Up @@ -717,8 +717,7 @@ def get_resolved_bugs(self) -> list[str]:

def _report_errors_for_each_branch(self, message: str) -> None:
body_msg = (
f"{message}\n\n---\n\n*Get in [touch with us]({CONTACTS_URL}) if you "
f"need some help.*\n"
f"{message}\n\n---\n\n*Get in [touch with us]({CONTACTS_URL}) if you need some help.*\n"
)
long_message = update_message_with_configured_failure_comment_message(
body_msg,
Expand Down Expand Up @@ -1162,7 +1161,7 @@ def get_trigger_type_description(self) -> str:
)
elif self.data.event_type == PushPagureEvent.__name__:
trigger_type_description += (
f"Fedora Koji build was triggered " f"by push with sha {self.data.commit_sha}."
f"Fedora Koji build was triggered by push with sha {self.data.commit_sha}."
)
elif self.data.event_type == KojiBuildTagEvent.__name__:
trigger_type_description += (
Expand Down Expand Up @@ -1227,7 +1226,7 @@ def get_branches(self) -> list[str]:
return self.branches

def get_trigger_type_description(self) -> str:
return f"Fedora Koji build was re-triggered " f"by comment in issue {self.data.issue_id}."
return f"Fedora Koji build was re-triggered by comment in issue {self.data.issue_id}."


@configured_as(job_type=JobType.koji_build)
Expand Down
5 changes: 2 additions & 3 deletions packit_service/worker/handlers/forges.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def run(self) -> TaskResults:
TaskResults
"""
logger.debug(
f"Going to run verification of FAS account triggered by comment:" f" {self.comment}",
f"Going to run verification of FAS account triggered by comment: {self.comment}",
)
# e.g. User Bebaabeni needs to be approved.
_, account_login, _ = self.issue.title.split(maxsplit=2)
Expand Down Expand Up @@ -247,8 +247,7 @@ def verify(self, namespace: str, fas_account: str) -> TaskResults:
sender_login=self.sender_login,
):
msg = (
f"Namespace `{namespace}` approved successfully "
f"using FAS account `{fas_account}`!"
f"Namespace `{namespace}` approved successfully using FAS account `{fas_account}`!"
)
logger.debug(msg)
self.issue.comment(msg)
Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/handlers/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def project_name(self) -> str:

@property
def image_name(self) -> str:
return f"{self.owner}/" f"{self.project_name}/{self.data.pr_id}"
return f"{self.owner}/{self.project_name}/{self.data.pr_id}"

@property
def image_distribution(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/handlers/open_scan_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def check_scan_and_build(self):
success=True,
details={
"msg": (
"No job configuration found for OpenScanHub task" f" in {self.project.repo}"
f"No job configuration found for OpenScanHub task in {self.project.repo}"
),
},
)
Expand Down
5 changes: 2 additions & 3 deletions packit_service/worker/helpers/build/babysit.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def update_vm_image_build(build_id: int, build: "VMImageBuildTargetModel"):
status = VMImageBuildStatus.error
except Exception as ex:
message = (
f"There was an exception when getting status of the VM " f"Image Build {build_id}: {ex}"
f"There was an exception when getting status of the VM Image Build {build_id}: {ex}"
)
logger.error(message)
# keep polling
Expand Down Expand Up @@ -546,8 +546,7 @@ def update_vm_image_build(build_id: int, build: "VMImageBuildTargetModel"):
if not packages_config:
build.set_status(status)
logger.debug(
f"No package config found for {build.build_id}. "
"No feedback can be given to the user.",
f"No package config found for {build.build_id}. No feedback can be given to the user.",
)
return True

Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/helpers/build/copr_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ def create_or_update_copr_project(self) -> str:
)
except PackitCoprSettingsException as ex:
# notify user first, PR if exists, commit comment otherwise
table = "| field | old value | new value |\n" "| ----- | --------- | --------- |\n"
table = "| field | old value | new value |\n| ----- | --------- | --------- |\n"
for field, (old, new) in ex.fields_to_change.items():
table += f"| {field} | {old} | {new} |\n"

Expand Down
6 changes: 3 additions & 3 deletions packit_service/worker/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def create_tasks(
handler_kls.get_signature(event=self.event, job=job_config),
)
logger.debug(
f"Got signature for handler={handler_kls} " f"and job_config={job_config}.",
f"Got signature for handler={handler_kls} and job_config={job_config}.",
)
processing_results.append(
TaskResults.create_from(
Expand Down Expand Up @@ -682,11 +682,11 @@ def is_project_public_or_enabled_private(self) -> bool:
# CoprBuildEvent.get_project returns None when the build id is not known
elif not self.event.project:
logger.warning(
"Cannot obtain project from this event! " "Skipping private repository check!",
"Cannot obtain project from this event! Skipping private repository check!",
)
elif self.event.project.is_private():
service_with_namespace = (
f"{self.event.project.service.hostname}/" f"{self.event.project.namespace}"
f"{self.event.project.service.hostname}/{self.event.project.namespace}"
)
if service_with_namespace not in self.service_config.enabled_private_namespaces:
logger.info(
Expand Down
3 changes: 1 addition & 2 deletions packit_service/worker/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ def __init__(self):

self.events_not_handled = Counter(
"events_not_handled",
"The number of events resulting in a Celery task, "
"but then dropped during processing",
"The number of events resulting in a Celery task, but then dropped during processing",
registry=self.registry,
)

Expand Down
17 changes: 4 additions & 13 deletions packit_service/worker/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,7 @@ def get_gitlab_push_common_data(event) -> tuple:
)
parsed_url = parse_git_repo(potential_url=project_url)
logger.info(
f"Project: "
f"repo={parsed_url.repo} "
f"namespace={parsed_url.namespace} "
f"url={project_url}.",
f"Project: repo={parsed_url.repo} namespace={parsed_url.namespace} url={project_url}.",
)
ref = raw_ref.split("/", maxsplit=2)[-1]

Expand Down Expand Up @@ -774,10 +771,7 @@ def parse_gitlab_issue_comment_event(event) -> Optional[IssueCommentGitlabEvent]
return None
parsed_url = parse_git_repo(potential_url=project_url)
logger.info(
f"Project: "
f"repo={parsed_url.repo} "
f"namespace={parsed_url.namespace} "
f"url={project_url}.",
f"Project: repo={parsed_url.repo} namespace={parsed_url.namespace} url={project_url}.",
)

actor = nested_get(event, "user", "username")
Expand Down Expand Up @@ -901,7 +895,7 @@ def parse_gitlab_commit_comment_event(
comment = nested_get(event, "object_attributes", "note")
comment_id = nested_get(event, "object_attributes", "id")
logger.info(
f"Gitlab commit comment on #{commit_sha}: {comment!r} id#{comment_id} " " event.",
f"Gitlab commit comment on #{commit_sha}: {comment!r} id#{comment_id} event.",
)

project_url = nested_get(event, "project", "web_url")
Expand All @@ -911,10 +905,7 @@ def parse_gitlab_commit_comment_event(

parsed_url = parse_git_repo(potential_url=project_url)
logger.info(
f"Project: "
f"repo={parsed_url.repo} "
f"namespace={parsed_url.namespace} "
f"url={project_url}.",
f"Project: repo={parsed_url.repo} namespace={parsed_url.namespace} url={project_url}.",
)

actor = nested_get(event, "user", "username")
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_vm_image_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_vm_image_build(github_vm_image_build_comment):
)
flexmock(group).should_receive("apply_async").times(1)
repo_download_url = (
"https://download.copr.fedorainfracloud.org/" "results/mmassari/knx-stack/fedora-36-x86_64/"
"https://download.copr.fedorainfracloud.org/results/mmassari/knx-stack/fedora-36-x86_64/"
)
flexmock(CoprHelper).should_receive("get_repo_download_url").once().and_return(
repo_download_url,
Expand Down
Loading

0 comments on commit 25ba508

Please sign in to comment.