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 <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-04-19 21:54:16 +08:00
parent b897676e01
commit e47d229528
+7 -10
View File
@@ -324,16 +324,13 @@ def _parse_grouped_sections(
def flush_group() -> None: def flush_group() -> None:
nonlocal current_group_name, current_group_cats nonlocal current_group_name, current_group_cats
if not current_group_cats: if current_group_cats:
current_group_name = None name = current_group_name or "Other"
current_group_cats = [] groups.append(ParsedGroup(
return name=name,
name = current_group_name or "Other" slug=slugify(name),
groups.append(ParsedGroup( categories=list(current_group_cats),
name=name, ))
slug=slugify(name),
categories=list(current_group_cats),
))
current_group_name = None current_group_name = None
current_group_cats = [] current_group_cats = []