Skip to content

Commit 93cb08e

Browse files
committed
Refactor type hints in cherry_pick_v2.py for consistency
This commit updates the `cherry_pick_v2.py` script to ensure consistent use of type hints by removing unnecessary comments that specify the `PullRequest` type. This change enhances code clarity and maintains flexibility in handling various object types. Key changes: - Removed comments indicating specific types for `pull_requests` and related functions. - Streamlined function signatures to improve readability and maintainability.
1 parent ccca540 commit 93cb08e

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

.github/actions/validate_pr_description/validate_pr_description.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def generate_backport_table(pr_number: int, app_domain: str) -> str:
177177
url = f"{base_url}?{query_string}"
178178
url_ui = f"{base_url}?{query_string}&ui=true"
179179

180-
rows.append(f"| **{branch}** [![▶ {branch}](https://img.shields.io/badge/%E2%96%B6_{branch.replace('-', '_')}-4caf50?style=flat-square)]({url}) [![⚙️](https://img.shields.io/badge/%E2%9A%99%EF%B8%8F-ff9800?style=flat-square)]({url_ui}) |")
180+
rows.append(f"| [![▶ {branch}](https://img.shields.io/badge/%E2%96%B6_{branch.replace('-', '_')}-4caf50?style=flat-square)]({url}) [![⚙️](https://img.shields.io/badge/%E2%9A%99%EF%B8%8F-ff9800?style=flat-square)]({url_ui}) |")
181181

182182
# Generate URL for backporting multiple branches
183183
all_branches = ",".join(branches)

.github/scripts/cherry_pick_v2.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
Maintains order of input sources and creates PRs with proper metadata.
66
"""
77

8-
from __future__ import annotations
9-
108
import os
119
import sys
1210
import datetime
@@ -42,13 +40,13 @@ class Source:
4240
title: str
4341
body_item: str
4442
author: Optional[str]
45-
pull_requests: List[Any] # github.PullRequest.PullRequest
43+
pull_requests: List[Any]
4644

4745

4846
@dataclass
4947
class BackportResult:
5048
target_branch: str
51-
pr: Optional[Any] = None # github.PullRequest.PullRequest
49+
pr: Optional[Any] = None
5250
conflict_files: List[ConflictInfo] = field(default_factory=list)
5351
cherry_pick_logs: List[str] = field(default_factory=list)
5452

@@ -110,7 +108,7 @@ def create_commit_source(commit, repo, logger) -> Source:
110108
)
111109

112110

113-
def create_pr_source(pull: Any, allow_unmerged: bool, logger) -> Source: # pull: github.PullRequest.PullRequest
111+
def create_pr_source(pull: Any, allow_unmerged: bool, logger) -> Source:
114112
"""Creates source from PR"""
115113
if not pull.merged:
116114
commit_shas = [c.sha for c in pull.get_commits()]
@@ -157,7 +155,7 @@ def detect_conflicts(repo_path: str, logger) -> List[ConflictInfo]:
157155
return conflict_files
158156

159157

160-
def get_linked_issues(repo, token: str, pull_requests: List[Any], logger) -> str: # pull_requests: List[github.PullRequest.PullRequest]
158+
def get_linked_issues(repo, token: str, pull_requests: List[Any], logger) -> str:
161159
"""Gets linked issues for all PRs"""
162160
all_issues = []
163161
owner, repo_name = repo.full_name.split('/')
@@ -387,7 +385,7 @@ def build_pr_content(
387385
return title, body
388386

389387

390-
def find_existing_backport_comment(pull: Any, logger): # pull: github.PullRequest.PullRequest
388+
def find_existing_backport_comment(pull: Any, logger):
391389
"""Finds existing backport comment"""
392390
try:
393391
for comment in pull.get_issue_comments():
@@ -398,7 +396,7 @@ def find_existing_backport_comment(pull: Any, logger): # pull: github.PullReque
398396
return None
399397

400398

401-
def update_comments(backport_comments: List[Tuple[Any, object]], results: List, skipped_branches: List[Tuple[str, str]], target_branches: List[str], workflow_url: Optional[str], logger): # backport_comments: List[Tuple[github.PullRequest.PullRequest, object]]
399+
def update_comments(backport_comments: List[Tuple[Any, object]], results: List, skipped_branches: List[Tuple[str, str]], target_branches: List[str], workflow_url: Optional[str], logger):
402400
"""Updates comments with backport results"""
403401
if not backport_comments:
404402
return

0 commit comments

Comments
 (0)