13
13
#
14
14
# END HEADER
15
15
16
+ from typing import Any , Tuple , overload
17
+
16
18
from hypothesis .errors import InvalidArgument
17
19
from hypothesis .internal .conjecture import utils as cu
18
20
from hypothesis .internal .conjecture .junkdrawer import LazySequenceCopy
19
21
from hypothesis .internal .conjecture .utils import combine_labels
20
22
from hypothesis .strategies ._internal .strategies import (
23
+ T3 ,
24
+ T4 ,
25
+ T5 ,
26
+ Ex ,
21
27
MappedSearchStrategy ,
22
28
SearchStrategy ,
29
+ T ,
23
30
check_strategy ,
24
31
filter_not_satisfied ,
25
32
)
@@ -44,10 +51,7 @@ def calc_label(self):
44
51
)
45
52
46
53
def __repr__ (self ):
47
- if len (self .element_strategies ) == 1 :
48
- tuple_string = f"{ self .element_strategies [0 ]!r} ,"
49
- else :
50
- tuple_string = ", " .join (map (repr , self .element_strategies ))
54
+ tuple_string = ", " .join (map (repr , self .element_strategies ))
51
55
return f"TupleStrategy(({ tuple_string } ))"
52
56
53
57
def calc_has_reusable_values (self , recur ):
@@ -60,9 +64,59 @@ def calc_is_empty(self, recur):
60
64
return any (recur (e ) for e in self .element_strategies )
61
65
62
66
67
+ @overload
68
+ def tuples () -> SearchStrategy [Tuple [()]]:
69
+ raise NotImplementedError
70
+
71
+
72
+ @overload # noqa: F811
73
+ def tuples (a1 : SearchStrategy [Ex ]) -> SearchStrategy [Tuple [Ex ]]:
74
+ raise NotImplementedError
75
+
76
+
77
+ @overload # noqa: F811
78
+ def tuples (
79
+ a1 : SearchStrategy [Ex ], a2 : SearchStrategy [T ]
80
+ ) -> SearchStrategy [Tuple [Ex , T ]]:
81
+ raise NotImplementedError
82
+
83
+
84
+ @overload # noqa: F811
85
+ def tuples (
86
+ a1 : SearchStrategy [Ex ], a2 : SearchStrategy [T ], a3 : SearchStrategy [T3 ]
87
+ ) -> SearchStrategy [Tuple [Ex , T , T3 ]]:
88
+ raise NotImplementedError
89
+
90
+
91
+ @overload # noqa: F811
92
+ def tuples (
93
+ a1 : SearchStrategy [Ex ],
94
+ a2 : SearchStrategy [T ],
95
+ a3 : SearchStrategy [T3 ],
96
+ a4 : SearchStrategy [T4 ],
97
+ ) -> SearchStrategy [Tuple [Ex , T , T3 , T4 ]]:
98
+ raise NotImplementedError
99
+
100
+
101
+ @overload # noqa: F811
102
+ def tuples (
103
+ a1 : SearchStrategy [Ex ],
104
+ a2 : SearchStrategy [T ],
105
+ a3 : SearchStrategy [T3 ],
106
+ a4 : SearchStrategy [T4 ],
107
+ a5 : SearchStrategy [T5 ],
108
+ ) -> SearchStrategy [Tuple [Ex , T , T3 , T4 , T5 ]]:
109
+ raise NotImplementedError
110
+
111
+
112
+ @overload # noqa: F811
113
+ def tuples (* args : SearchStrategy [Any ]) -> SearchStrategy [Tuple ]:
114
+ raise NotImplementedError
115
+
116
+
63
117
@cacheable
64
118
@defines_strategy ()
65
- def tuples (* args : SearchStrategy ) -> SearchStrategy [ tuple ]:
119
+ def tuples (* args ): # noqa: F811
66
120
"""Return a strategy which generates a tuple of the same length as args by
67
121
generating the value at index i from args[i].
68
122
0 commit comments