Skip to content

Commit 4385757

Browse files
committed
Return Path from notes_path; use Path.is_file in seal checker
Per review: treat these helper scripts as private, so notes_path can return Path and drop the str/Path round-trip at its call site. Accept the behavioral change from os.path.isfile to Path.is_file in check_generated_file_seals.
1 parent d825cec commit 4385757

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎ci/tools/check_release_notes.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ def is_backport_version(version: str, backport_branch: str) -> bool:
8585
return version == backport_branch
8686

8787

88-
def notes_path(package: str, version: str) -> str:
89-
return str(Path(package, "docs", "source", "release", f"{version}-notes.rst"))
88+
def notes_path(package: str, version: str) -> Path:
89+
return Path(package, "docs", "source", "release", f"{version}-notes.rst")
9090

9191

92-
def check_release_notes(git_tag: str, component: str, repo_root: str = ".") -> list[tuple[str, str]]:
92+
def check_release_notes(git_tag: str, component: str, repo_root: str = ".") -> list[tuple[str | Path, str]]:
9393
"""Return a list of (path, reason) for missing or empty release notes.
9494
95+
``path`` is the repo-relative notes path, or a ``<placeholder>`` naming the
96+
offending argument when the tag or component itself is the problem.
97+
9598
Returns an empty list when notes are present and non-empty, or when the
9699
tag is a .post release (no new notes required).
97100
"""
@@ -106,7 +109,7 @@ def check_release_notes(git_tag: str, component: str, repo_root: str = ".") -> l
106109
return []
107110

108111
path = notes_path(COMPONENT_TO_PACKAGE[component], version)
109-
full = Path(repo_root, path)
112+
full = Path(repo_root) / path
110113
if not full.is_file():
111114
return [(path, "missing")]
112115
if full.stat().st_size == 0:
@@ -124,7 +127,7 @@ def write_step_summary(message: str) -> None:
124127
f.write("\n")
125128

126129

127-
def warn_missing_backport_notes(git_tag: str, component: str, problems: list[tuple[str, str]]) -> None:
130+
def warn_missing_backport_notes(git_tag: str, component: str, problems: list[tuple[str | Path, str]]) -> None:
128131
print(f"WARNING: missing or empty release notes for backport tag {git_tag}:")
129132
summary_lines = [
130133
"## Release Notes Reminder",
@@ -149,7 +152,7 @@ def validate_backport_decision(
149152
backport_git_tag: str,
150153
backport_branch: str | None,
151154
repo_root: str,
152-
) -> tuple[int | None, list[tuple[str, str]]]:
155+
) -> tuple[int | None, list[tuple[str | Path, str]]]:
153156
if component not in BACKPORT_PLANNING_COMPONENTS or is_post_release(version):
154157
return None, []
155158

‎toolshed/check_generated_file_seals.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import hashlib
5-
import os
65
import re
76
import subprocess
87
import sys
@@ -142,9 +141,7 @@ def main(args):
142141

143142
returncode = 0
144143
for filepath in args:
145-
# os.path.isfile, not Path.is_file: this skips anything that is not a
146-
# readable regular file, and Path.is_file raises on e.g. EACCES.
147-
if not os.path.isfile(filepath):
144+
if not Path(filepath).is_file():
148145
continue
149146
if not validate_generated_file_seal(filepath, previously_sealed_paths):
150147
returncode = 1

0 commit comments

Comments
 (0)