Skip to content

Commit

Permalink
Return proper values in merger.py. Do not use int
Browse files Browse the repository at this point in the history
in case it is boolean

Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Jan 17, 2025
1 parent 6d83b02 commit ea99f84
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions auto_merger/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_gh_pr_list(self):
continue
self.repo_data.append(pr)

def is_authenticated(self):
def is_authenticated(self) -> bool:
token = os.getenv("GH_TOKEN")
if token == "":
logger.error("Environment variable GH_TOKEN is not specified.")
Expand All @@ -96,7 +96,7 @@ def is_authenticated(self):
return False
return True

def check_labels_to_merge(self, pr):
def check_labels_to_merge(self, pr) -> bool:
if "labels" not in pr:
return False
logger.debug(f"check_labels_to_merge for {self.container_name}: {pr['labels']} and {self.approval_labels}")
Expand Down Expand Up @@ -212,9 +212,9 @@ def merge_pr(self):
logger.error(f"Merging pr {pr} failed with reason {cpe.output}")
continue

def check_all_containers(self) -> int:
def check_all_containers(self) -> bool:
if not self.is_authenticated():
return 1
return False
self.temp_dir = utils.temporary_dir()
for container in self.config.github["repos"]:
self.container_name = container
Expand All @@ -235,14 +235,14 @@ def check_all_containers(self) -> int:
logger.error(f"Something went wrong {self.container_name}.")
continue
os.chdir(self.current_dir)
return 0
return True

def print_pull_request_to_merge(self):
# Do not print anything in case we do not have PR.
if not [x for x in self.pr_to_merge if self.pr_to_merge[x]]:
logger.info(f"Nothing to be merged in repos {self.config.github['repos']} "
f"in organization {self.namespace}")
return 0
return
to_approval: bool = False
pr_body: list[str] = []
logger.info("SUMMARY")
Expand Down Expand Up @@ -274,7 +274,7 @@ def print_pull_request_to_merge(self):
def send_results(self, recipients):
logger.debug(f"Recipients are: {recipients}")
if not recipients:
return 1
return False
sender_class = EmailSender(recipient_email=list(recipients))
subject_msg = f"Pull request statuses for organization https://github.com/{self.namespace}"
if self.approval_body:
Expand Down

0 comments on commit ea99f84

Please sign in to comment.