Skip to content

Commit 1667e85

Browse files
gh-64502: Simplify comments in the option group parsing code
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent b4c3487 commit 1667e85

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

Tools/clinic/libclinic/clanguage.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
def count_required(subset: ParamTuple) -> int:
2424
"""Return the number of arguments which cannot be omitted.
2525
26-
Trailing parameters with a default value which are not in an optional
27-
group can be omitted.
26+
A parameter in an optional group is passed together with its group,
27+
so only trailing parameters with a default value can be omitted.
2828
"""
2929
count = len(subset)
3030
for p in reversed(subset):
@@ -314,9 +314,7 @@ def render_option_group_parsing(
314314
assert group is not None
315315
group.append(p)
316316

317-
# Map the number of arguments to the subset which accepts them.
318-
# A subset accepts a range of counts, because its trailing parameters
319-
# with a default value which are not in any group can be omitted.
317+
# Map the number of arguments to the subset which accepts it.
320318
subsets: dict[int, ParamTuple] = {}
321319
for subset in permute_optional_groups(left, required, right):
322320
for count in range(count_required(subset), len(subset) + 1):
@@ -333,8 +331,7 @@ def render_option_group_parsing(
333331
out.append(f"switch ({nargs}) {{\n")
334332
for count, subset in sorted(subsets.items()):
335333
if count < len(subset):
336-
# Some of the trailing parameters are omitted;
337-
# they are parsed together with the following case.
334+
# The omitted parameters are parsed by the following case.
338335
out.append(f" case {count}:\n")
339336
continue
340337

0 commit comments

Comments
 (0)