Skip to content

Commit 11026b5

Browse files
Apply suggestions from code review
Apply suggestions for cleaner code by removing unnecessary ternaries and adjusting `ParsedComment` appropriately. Co-authored-by: Matej Focko <[email protected]>
1 parent b0ab330 commit 11026b5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packit_service/worker/jobs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797

9898
@dataclass
9999
class ParsedComment:
100-
command: str
101-
package: str
100+
command: Optional[str] = None
101+
package: Optional[str] = None
102102

103103

104104
def parse_comment(
@@ -122,7 +122,7 @@ def parse_comment(
122122
"""
123123
commands = get_packit_commands_from_comment(comment, packit_comment_command_prefix)
124124
if not commands:
125-
return None
125+
return ParsedComment()
126126

127127
if comment.startswith("/packit-ci"):
128128
parser = get_pr_comment_parser_fedora_ci(
@@ -143,7 +143,7 @@ def parse_comment(
143143
except SystemExit:
144144
# tests expect invalid syntax comments be ignored
145145
logger.debug(f"Command {commands} uses unexpected syntax.")
146-
return None
146+
return ParsedComment()
147147

148148

149149
def get_handlers_for_command(
@@ -555,7 +555,7 @@ def is_packit_config_present(self) -> bool:
555555
self.event.comment,
556556
self.service_config.comment_command_prefix,
557557
)
558-
command = arguments.command if arguments else ""
558+
command = arguments.command
559559

560560
if handlers := get_handlers_for_command(command):
561561
# we require packit config file when event is triggered by /packit command
@@ -599,8 +599,8 @@ def process_fedora_ci_jobs(self) -> list[TaskResults]:
599599
)
600600

601601
# [XXX] if there are ever monorepos in Fedora CI…
602-
# monorepo_package = arguments.package if arguments else ""
603-
command = arguments.command if arguments else ""
602+
# monorepo_package = arguments.package
603+
command = arguments.command
604604
handlers_triggered_by_job = get_handlers_for_command_fedora_ci(command)
605605

606606
matching_handlers = {
@@ -674,8 +674,8 @@ def process_jobs(self) -> list[TaskResults]:
674674
self.service_config.comment_command_prefix,
675675
)
676676

677-
monorepo_package = arguments.package if arguments else ""
678-
command = arguments.command if arguments else ""
677+
monorepo_package = arguments.package
678+
command = arguments.command
679679

680680
if not get_handlers_for_command(command):
681681
return [
@@ -1018,7 +1018,7 @@ def get_handlers_for_comment_and_rerun_event(self) -> set[type[JobHandler]]:
10181018
self.service_config.comment_command_prefix,
10191019
)
10201020

1021-
command = arguments.command if arguments else ""
1021+
command = arguments.command
10221022
handlers_triggered_by_job = get_handlers_for_command(command)
10231023

10241024
if handlers_triggered_by_job and not isinstance(

0 commit comments

Comments
 (0)