Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2208751

Browse files
gh-104050: Annotate Argument Clinic parameter permutation helpers (#106431)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent110b97c commit2208751

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

‎Tools/clinic/clinic.py‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
importtextwrap
2929
importtraceback
3030

31-
fromcollections.abcimportCallable
31+
fromcollections.abcimport (
32+
Callable,
33+
Iterable,
34+
Iterator,
35+
Sequence,
36+
)
3237
fromtypesimportFunctionType,NoneType
3338
fromtypingimport (
3439
Any,
@@ -516,7 +521,13 @@ class PythonLanguage(Language):
516521
checksum_line="#/*[{dsl_name} end generated code: {arguments}]*/"
517522

518523

519-
defpermute_left_option_groups(l):
524+
ParamGroup=Iterable["Parameter"]
525+
ParamTuple=tuple["Parameter", ...]
526+
527+
528+
defpermute_left_option_groups(
529+
l:Sequence[ParamGroup]
530+
)->Iterator[ParamTuple]:
520531
"""
521532
Given [(1,), (2,), (3,)], should yield:
522533
()
@@ -525,13 +536,15 @@ def permute_left_option_groups(l):
525536
(1, 2, 3)
526537
"""
527538
yieldtuple()
528-
accumulator= []
539+
accumulator:list[Parameter]= []
529540
forgroupinreversed(l):
530541
accumulator=list(group)+accumulator
531542
yieldtuple(accumulator)
532543

533544

534-
defpermute_right_option_groups(l):
545+
defpermute_right_option_groups(
546+
l:Sequence[ParamGroup]
547+
)->Iterator[ParamTuple]:
535548
"""
536549
Given [(1,), (2,), (3,)], should yield:
537550
()
@@ -540,13 +553,17 @@ def permute_right_option_groups(l):
540553
(1, 2, 3)
541554
"""
542555
yieldtuple()
543-
accumulator= []
556+
accumulator:list[Parameter]= []
544557
forgroupinl:
545558
accumulator.extend(group)
546559
yieldtuple(accumulator)
547560

548561

549-
defpermute_optional_groups(left,required,right):
562+
defpermute_optional_groups(
563+
left:Sequence[ParamGroup],
564+
required:ParamGroup,
565+
right:Sequence[ParamGroup]
566+
)->tuple[ParamTuple, ...]:
550567
"""
551568
Generator function that computes the set of acceptable
552569
argument lists for the provided iterables of
@@ -561,7 +578,7 @@ def permute_optional_groups(left, required, right):
561578
ifleft:
562579
raiseValueError("required is empty but left is not")
563580

564-
accumulator= []
581+
accumulator:list[ParamTuple]= []
565582
counts=set()
566583
forrinpermute_right_option_groups(right):
567584
forlinpermute_left_option_groups(left):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp