Skip to content

Commit 76fa16c

Browse files
Fix: Resolve UnboundLocalError for processed_comments_count
- Ensures `processed_comments_count` is initialized to 0 at the beginning of the `main()` function scope, alongside other tracking variables like `latest_overall_review_activity_dt` and `latest_line_comment_activity_dt`. - This prevents an `UnboundLocalError` when the script attempts to print the number of processed line comments in scenarios where the line comment processing loop is skipped (e.g., if no line comments are fetched). This commit finalizes fixes for variable initialization and scoping issues.
1 parent 01eaf8a commit 76fa16c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/print_github_reviews.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ def parse_repo_url(url_string):
284284
args = parser.parse_args()
285285
error_suffix = " (use --help for more details)"
286286

287+
# Initialize tracking variables early, including processed_comments_count
288+
latest_overall_review_activity_dt = None
289+
latest_line_comment_activity_dt = None
290+
processed_comments_count = 0
291+
287292
if not args.token:
288293
sys.stderr.write(f"Error: GitHub token not provided. Set GITHUB_TOKEN or use --token.{error_suffix}\n")
289294
sys.exit(1)
@@ -474,10 +479,8 @@ def parse_repo_url(url_string):
474479
# Note: The decision to exit if only line comments fail vs. if only overall reviews fail could be nuanced.
475480
# For now, failure to fetch either is treated as a critical error for the script's purpose.
476481

477-
# Initialize tracking variables early - MOVED TO TOP OF MAIN
478-
# latest_overall_review_activity_dt = None
479-
# latest_line_comment_activity_dt = None
480-
# processed_comments_count = 0 # This is specifically for line comments
482+
# Initializations for latest_overall_review_activity_dt, latest_line_comment_activity_dt,
483+
# and processed_comments_count have been moved to the top of the main() function.
481484

482485
# Handling for line comments
483486
if not comments: # comments is an empty list here (None case handled above)

0 commit comments

Comments
 (0)