From e47d22952862630b1636bb8a6fa322d93ee3d973 Mon Sep 17 00:00:00 2001 From: Vinta Chen Date: Sun, 19 Apr 2026 21:54:16 +0800 Subject: [PATCH] refactor(readme_parser): consolidate state reset to tail of flush_group State reset (current_group_name = None, current_group_cats = []) was duplicated in both branches of the early-return guard. Move it after the conditional so it runs exactly once regardless of path. Co-Authored-By: Claude --- website/readme_parser.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/website/readme_parser.py b/website/readme_parser.py index c736b7cc..b527c24e 100644 --- a/website/readme_parser.py +++ b/website/readme_parser.py @@ -324,16 +324,13 @@ def _parse_grouped_sections( def flush_group() -> None: nonlocal current_group_name, current_group_cats - if not current_group_cats: - current_group_name = None - current_group_cats = [] - return - name = current_group_name or "Other" - groups.append(ParsedGroup( - name=name, - slug=slugify(name), - categories=list(current_group_cats), - )) + if current_group_cats: + name = current_group_name or "Other" + groups.append(ParsedGroup( + name=name, + slug=slugify(name), + categories=list(current_group_cats), + )) current_group_name = None current_group_cats = []