basedpyright 1.12.6 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/pyright-langserver.js +1 -1
  2. package/dist/pyright-langserver.js.map +1 -1
  3. package/dist/pyright.js +1 -1
  4. package/dist/pyright.js.map +1 -1
  5. package/dist/typeshed-fallback/stdlib/_ast.pyi +279 -42
  6. package/dist/typeshed-fallback/stdlib/_bisect.pyi +149 -12
  7. package/dist/typeshed-fallback/stdlib/_codecs.pyi +125 -14
  8. package/dist/typeshed-fallback/stdlib/_csv.pyi +130 -7
  9. package/dist/typeshed-fallback/stdlib/_ctypes.pyi +72 -17
  10. package/dist/typeshed-fallback/stdlib/_curses.pyi +626 -78
  11. package/dist/typeshed-fallback/stdlib/_decimal.pyi +775 -153
  12. package/dist/typeshed-fallback/stdlib/_heapq.pyi +61 -5
  13. package/dist/typeshed-fallback/stdlib/_imp.pyi +70 -15
  14. package/dist/typeshed-fallback/stdlib/_json.pyi +55 -12
  15. package/dist/typeshed-fallback/stdlib/_locale.pyi +63 -12
  16. package/dist/typeshed-fallback/stdlib/_lsprof.pyi +61 -4
  17. package/dist/typeshed-fallback/stdlib/_operator.pyi +238 -62
  18. package/dist/typeshed-fallback/stdlib/_posixsubprocess.pyi +25 -1
  19. package/dist/typeshed-fallback/stdlib/_random.pyi +23 -5
  20. package/dist/typeshed-fallback/stdlib/_socket.pyi +618 -63
  21. package/dist/typeshed-fallback/stdlib/_stat.pyi +140 -13
  22. package/dist/typeshed-fallback/stdlib/_thread.pyi +215 -22
  23. package/dist/typeshed-fallback/stdlib/_tkinter.pyi +44 -11
  24. package/dist/typeshed-fallback/stdlib/_tracemalloc.pyi +71 -10
  25. package/dist/typeshed-fallback/stdlib/_warnings.pyi +53 -6
  26. package/dist/typeshed-fallback/stdlib/_weakref.pyi +43 -10
  27. package/dist/typeshed-fallback/stdlib/_winapi.pyi +255 -255
  28. package/dist/typeshed-fallback/stdlib/array.pyi +233 -44
  29. package/dist/typeshed-fallback/stdlib/atexit.pyi +50 -5
  30. package/dist/typeshed-fallback/stdlib/audioop.pyi +78 -26
  31. package/dist/typeshed-fallback/stdlib/binascii.pyi +105 -18
  32. package/dist/typeshed-fallback/stdlib/builtins.pyi +5254 -829
  33. package/dist/typeshed-fallback/stdlib/cmath.pyi +99 -23
  34. package/dist/typeshed-fallback/stdlib/errno.pyi +15 -0
  35. package/dist/typeshed-fallback/stdlib/faulthandler.pyi +33 -8
  36. package/dist/typeshed-fallback/stdlib/fcntl.pyi +199 -8
  37. package/dist/typeshed-fallback/stdlib/gc.pyi +130 -18
  38. package/dist/typeshed-fallback/stdlib/grp.pyi +58 -7
  39. package/dist/typeshed-fallback/stdlib/itertools.pyi +281 -42
  40. package/dist/typeshed-fallback/stdlib/marshal.pyi +82 -4
  41. package/dist/typeshed-fallback/stdlib/math.pyi +357 -61
  42. package/dist/typeshed-fallback/stdlib/mmap.pyi +47 -8
  43. package/dist/typeshed-fallback/stdlib/msvcrt.pyi +32 -32
  44. package/dist/typeshed-fallback/stdlib/nt.pyi +118 -111
  45. package/dist/typeshed-fallback/stdlib/parser.pyi +55 -24
  46. package/dist/typeshed-fallback/stdlib/posix.pyi +7 -0
  47. package/dist/typeshed-fallback/stdlib/pwd.pyi +60 -10
  48. package/dist/typeshed-fallback/stdlib/pyexpat/__init__.pyi +61 -12
  49. package/dist/typeshed-fallback/stdlib/readline.pyi +184 -27
  50. package/dist/typeshed-fallback/stdlib/resource.pyi +56 -16
  51. package/dist/typeshed-fallback/stdlib/select.pyi +97 -5
  52. package/dist/typeshed-fallback/stdlib/spwd.pyi +60 -11
  53. package/dist/typeshed-fallback/stdlib/sys/__init__.pyi +386 -48
  54. package/dist/typeshed-fallback/stdlib/syslog.pyi +27 -7
  55. package/dist/typeshed-fallback/stdlib/termios.pyi +88 -8
  56. package/dist/typeshed-fallback/stdlib/time.pyi +314 -37
  57. package/dist/typeshed-fallback/stdlib/unicodedata.pyi +264 -34
  58. package/dist/typeshed-fallback/stdlib/winreg.pyi +172 -132
  59. package/dist/typeshed-fallback/stdlib/zlib.pyi +108 -7
  60. package/package.json +1 -1
@@ -1,3 +1,33 @@
1
+ """
2
+ Functional tools for creating and using iterators.
3
+
4
+ Infinite iterators:
5
+ count(start=0, step=1) --> start, start+step, start+2*step, ...
6
+ cycle(p) --> p0, p1, ... plast, p0, p1, ...
7
+ repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times
8
+
9
+ Iterators terminating on the shortest input sequence:
10
+ accumulate(p[, func]) --> p0, p0+p1, p0+p1+p2
11
+ chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ...
12
+ chain.from_iterable([p, q, ...]) --> p0, p1, ... plast, q0, q1, ...
13
+ compress(data, selectors) --> (d[0] if s[0]), (d[1] if s[1]), ...
14
+ dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails
15
+ groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)
16
+ filterfalse(pred, seq) --> elements of seq where pred(elem) is False
17
+ islice(seq, [start,] stop [, step]) --> elements from
18
+ seq[start:stop:step]
19
+ starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...
20
+ tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n
21
+ takewhile(pred, seq) --> seq[0], seq[1], until pred fails
22
+ zip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
23
+
24
+ Combinatoric generators:
25
+ product(p, q, ... [repeat=1]) --> cartesian product
26
+ permutations(p[, r])
27
+ combinations(p, r)
28
+ combinations_with_replacement(p, r)
29
+ """
30
+
1
31
  import sys
2
32
  from collections.abc import Callable, Iterable, Iterator
3
33
  from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeVar, overload
@@ -29,91 +59,220 @@ _Predicate: TypeAlias = Callable[[_T], object]
29
59
  # Technically count can take anything that implements a number protocol and has an add method
30
60
  # but we can't enforce the add method
31
61
  class count(Iterator[_N]):
62
+ """
63
+ Return a count object whose .__next__() method returns consecutive values.
64
+
65
+ Equivalent to:
66
+ def count(firstval=0, step=1):
67
+ x = firstval
68
+ while 1:
69
+ yield x
70
+ x += step
71
+ """
32
72
  @overload
33
73
  def __new__(cls) -> count[int]: ...
34
74
  @overload
35
75
  def __new__(cls, start: _N, step: _Step = ...) -> count[_N]: ...
36
76
  @overload
37
77
  def __new__(cls, *, step: _N) -> count[_N]: ...
38
- def __next__(self) -> _N: ...
39
- def __iter__(self) -> Self: ...
78
+ def __next__(self) -> _N:
79
+ """Implement next(self)."""
80
+ ...
81
+ def __iter__(self) -> Self:
82
+ """Implement iter(self)."""
83
+ ...
40
84
 
41
85
  class cycle(Iterator[_T]):
86
+ """Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely."""
42
87
  def __init__(self, iterable: Iterable[_T], /) -> None: ...
43
- def __next__(self) -> _T: ...
44
- def __iter__(self) -> Self: ...
88
+ def __next__(self) -> _T:
89
+ """Implement next(self)."""
90
+ ...
91
+ def __iter__(self) -> Self:
92
+ """Implement iter(self)."""
93
+ ...
45
94
 
46
95
  class repeat(Iterator[_T]):
96
+ """
97
+ repeat(object [,times]) -> create an iterator which returns the object
98
+ for the specified number of times. If not specified, returns the object
99
+ endlessly.
100
+ """
47
101
  @overload
48
102
  def __init__(self, object: _T) -> None: ...
49
103
  @overload
50
104
  def __init__(self, object: _T, times: int) -> None: ...
51
- def __next__(self) -> _T: ...
52
- def __iter__(self) -> Self: ...
53
- def __length_hint__(self) -> int: ...
105
+ def __next__(self) -> _T:
106
+ """Implement next(self)."""
107
+ ...
108
+ def __iter__(self) -> Self:
109
+ """Implement iter(self)."""
110
+ ...
111
+ def __length_hint__(self) -> int:
112
+ """Private method returning an estimate of len(list(it))."""
113
+ ...
54
114
 
55
115
  class accumulate(Iterator[_T]):
116
+ """Return series of accumulated sums (or other binary function results)."""
56
117
  @overload
57
118
  def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
58
119
  @overload
59
120
  def __init__(self, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> None: ...
60
- def __iter__(self) -> Self: ...
61
- def __next__(self) -> _T: ...
121
+ def __iter__(self) -> Self:
122
+ """Implement iter(self)."""
123
+ ...
124
+ def __next__(self) -> _T:
125
+ """Implement next(self)."""
126
+ ...
62
127
 
63
128
  class chain(Iterator[_T]):
129
+ """
130
+ chain(*iterables) --> chain object
131
+
132
+ Return a chain object whose .__next__() method returns elements from the
133
+ first iterable until it is exhausted, then elements from the next
134
+ iterable, until all of the iterables are exhausted.
135
+ """
64
136
  def __init__(self, *iterables: Iterable[_T]) -> None: ...
65
- def __next__(self) -> _T: ...
66
- def __iter__(self) -> Self: ...
137
+ def __next__(self) -> _T:
138
+ """Implement next(self)."""
139
+ ...
140
+ def __iter__(self) -> Self:
141
+ """Implement iter(self)."""
142
+ ...
67
143
  @classmethod
68
144
  # We use type[Any] and not type[_S] to not lose the type inference from __iterable
69
- def from_iterable(cls: type[Any], iterable: Iterable[Iterable[_S]], /) -> chain[_S]: ...
145
+ def from_iterable(cls: type[Any], iterable: Iterable[Iterable[_S]], /) -> chain[_S]:
146
+ """Alternative chain() constructor taking a single iterable argument that evaluates lazily."""
147
+ ...
70
148
  if sys.version_info >= (3, 9):
71
- def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
149
+ def __class_getitem__(cls, item: Any, /) -> GenericAlias:
150
+ """See PEP 585"""
151
+ ...
72
152
 
73
153
  class compress(Iterator[_T]):
154
+ """
155
+ Return data elements corresponding to true selector elements.
156
+
157
+ Forms a shorter iterator from selected data elements using the selectors to
158
+ choose the data elements.
159
+ """
74
160
  def __init__(self, data: Iterable[_T], selectors: Iterable[Any]) -> None: ...
75
- def __iter__(self) -> Self: ...
76
- def __next__(self) -> _T: ...
161
+ def __iter__(self) -> Self:
162
+ """Implement iter(self)."""
163
+ ...
164
+ def __next__(self) -> _T:
165
+ """Implement next(self)."""
166
+ ...
77
167
 
78
168
  class dropwhile(Iterator[_T]):
169
+ """
170
+ Drop items from the iterable while predicate(item) is true.
171
+
172
+ Afterwards, return every element until the iterable is exhausted.
173
+ """
79
174
  def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
80
- def __iter__(self) -> Self: ...
81
- def __next__(self) -> _T: ...
175
+ def __iter__(self) -> Self:
176
+ """Implement iter(self)."""
177
+ ...
178
+ def __next__(self) -> _T:
179
+ """Implement next(self)."""
180
+ ...
82
181
 
83
182
  class filterfalse(Iterator[_T]):
183
+ """
184
+ Return those items of iterable for which function(item) is false.
185
+
186
+ If function is None, return the items that are false.
187
+ """
84
188
  def __init__(self, predicate: _Predicate[_T] | None, iterable: Iterable[_T], /) -> None: ...
85
- def __iter__(self) -> Self: ...
86
- def __next__(self) -> _T: ...
189
+ def __iter__(self) -> Self:
190
+ """Implement iter(self)."""
191
+ ...
192
+ def __next__(self) -> _T:
193
+ """Implement next(self)."""
194
+ ...
87
195
 
88
196
  class groupby(Iterator[tuple[_T_co, Iterator[_S_co]]], Generic[_T_co, _S_co]):
197
+ """
198
+ make an iterator that returns consecutive keys and groups from the iterable
199
+
200
+ iterable
201
+ Elements to divide into groups according to the key function.
202
+ key
203
+ A function for computing the group category for each element.
204
+ If the key function is not specified or is None, the element itself
205
+ is used for grouping.
206
+ """
89
207
  @overload
90
208
  def __new__(cls, iterable: Iterable[_T1], key: None = None) -> groupby[_T1, _T1]: ...
91
209
  @overload
92
210
  def __new__(cls, iterable: Iterable[_T1], key: Callable[[_T1], _T2]) -> groupby[_T2, _T1]: ...
93
- def __iter__(self) -> Self: ...
94
- def __next__(self) -> tuple[_T_co, Iterator[_S_co]]: ...
211
+ def __iter__(self) -> Self:
212
+ """Implement iter(self)."""
213
+ ...
214
+ def __next__(self) -> tuple[_T_co, Iterator[_S_co]]:
215
+ """Implement next(self)."""
216
+ ...
95
217
 
96
218
  class islice(Iterator[_T]):
219
+ """
220
+ islice(iterable, stop) --> islice object
221
+ islice(iterable, start, stop[, step]) --> islice object
222
+
223
+ Return an iterator whose next() method returns selected values from an
224
+ iterable. If start is specified, will skip all preceding elements;
225
+ otherwise, start defaults to zero. Step defaults to one. If
226
+ specified as another value, step determines how many values are
227
+ skipped between successive calls. Works like a slice() on a list
228
+ but returns an iterator.
229
+ """
97
230
  @overload
98
231
  def __init__(self, iterable: Iterable[_T], stop: int | None, /) -> None: ...
99
232
  @overload
100
233
  def __init__(self, iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = ..., /) -> None: ...
101
- def __iter__(self) -> Self: ...
102
- def __next__(self) -> _T: ...
234
+ def __iter__(self) -> Self:
235
+ """Implement iter(self)."""
236
+ ...
237
+ def __next__(self) -> _T:
238
+ """Implement next(self)."""
239
+ ...
103
240
 
104
241
  class starmap(Iterator[_T_co]):
242
+ """Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence."""
105
243
  def __new__(cls, function: Callable[..., _T], iterable: Iterable[Iterable[Any]], /) -> starmap[_T]: ...
106
- def __iter__(self) -> Self: ...
107
- def __next__(self) -> _T_co: ...
244
+ def __iter__(self) -> Self:
245
+ """Implement iter(self)."""
246
+ ...
247
+ def __next__(self) -> _T_co:
248
+ """Implement next(self)."""
249
+ ...
108
250
 
109
251
  class takewhile(Iterator[_T]):
252
+ """Return successive entries from an iterable as long as the predicate evaluates to true for each entry."""
110
253
  def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
111
- def __iter__(self) -> Self: ...
112
- def __next__(self) -> _T: ...
254
+ def __iter__(self) -> Self:
255
+ """Implement iter(self)."""
256
+ ...
257
+ def __next__(self) -> _T:
258
+ """Implement next(self)."""
259
+ ...
113
260
 
114
- def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]: ...
261
+ def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]:
262
+ """Returns a tuple of n independent iterators."""
263
+ ...
115
264
 
116
265
  class zip_longest(Iterator[_T_co]):
266
+ """
267
+ zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) --> zip_longest object
268
+
269
+ Return a zip_longest object whose .__next__() method returns a tuple where
270
+ the i-th element comes from the i-th iterable argument. The .__next__()
271
+ method continues until the longest iterable in the argument sequence
272
+ is exhausted and then it raises StopIteration. When the shorter iterables
273
+ are exhausted, the fillvalue is substituted in their place. The fillvalue
274
+ defaults to None or can be specified by a keyword argument.
275
+ """
117
276
  # one iterable (fillvalue doesn't matter)
118
277
  @overload
119
278
  def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
@@ -188,10 +347,31 @@ class zip_longest(Iterator[_T_co]):
188
347
  *iterables: Iterable[_T],
189
348
  fillvalue: _T,
190
349
  ) -> zip_longest[tuple[_T, ...]]: ...
191
- def __iter__(self) -> Self: ...
192
- def __next__(self) -> _T_co: ...
350
+ def __iter__(self) -> Self:
351
+ """Implement iter(self)."""
352
+ ...
353
+ def __next__(self) -> _T_co:
354
+ """Implement next(self)."""
355
+ ...
193
356
 
194
357
  class product(Iterator[_T_co]):
358
+ """
359
+ product(*iterables, repeat=1) --> product object
360
+
361
+ Cartesian product of input iterables. Equivalent to nested for-loops.
362
+
363
+ For example, product(A, B) returns the same as: ((x,y) for x in A for y in B).
364
+ The leftmost iterators are in the outermost for-loop, so the output tuples
365
+ cycle in a manner similar to an odometer (with the rightmost element changing
366
+ on every iteration).
367
+
368
+ To compute the product of an iterable with itself, specify the number
369
+ of repetitions with the optional repeat keyword argument. For example,
370
+ product(A, repeat=4) means the same as product(A, A, A, A).
371
+
372
+ product('ab', range(3)) --> ('a',0) ('a',1) ('a',2) ('b',0) ('b',1) ('b',2)
373
+ product((0,1), (0,1), (0,1)) --> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
374
+ """
195
375
  @overload
196
376
  def __new__(cls, iter1: Iterable[_T1], /) -> product[tuple[_T1]]: ...
197
377
  @overload
@@ -273,10 +453,19 @@ class product(Iterator[_T_co]):
273
453
  ) -> product[tuple[_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10]]: ...
274
454
  @overload
275
455
  def __new__(cls, *iterables: Iterable[_T1], repeat: int = 1) -> product[tuple[_T1, ...]]: ...
276
- def __iter__(self) -> Self: ...
277
- def __next__(self) -> _T_co: ...
456
+ def __iter__(self) -> Self:
457
+ """Implement iter(self)."""
458
+ ...
459
+ def __next__(self) -> _T_co:
460
+ """Implement next(self)."""
461
+ ...
278
462
 
279
463
  class permutations(Iterator[_T_co]):
464
+ """
465
+ Return successive r-length permutations of elements in the iterable.
466
+
467
+ permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
468
+ """
280
469
  @overload
281
470
  def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> permutations[tuple[_T, _T]]: ...
282
471
  @overload
@@ -287,10 +476,19 @@ class permutations(Iterator[_T_co]):
287
476
  def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> permutations[tuple[_T, _T, _T, _T, _T]]: ...
288
477
  @overload
289
478
  def __new__(cls, iterable: Iterable[_T], r: int | None = ...) -> permutations[tuple[_T, ...]]: ...
290
- def __iter__(self) -> Self: ...
291
- def __next__(self) -> _T_co: ...
479
+ def __iter__(self) -> Self:
480
+ """Implement iter(self)."""
481
+ ...
482
+ def __next__(self) -> _T_co:
483
+ """Implement next(self)."""
484
+ ...
292
485
 
293
486
  class combinations(Iterator[_T_co]):
487
+ """
488
+ Return successive r-length combinations of elements in the iterable.
489
+
490
+ combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
491
+ """
294
492
  @overload
295
493
  def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ...
296
494
  @overload
@@ -301,10 +499,19 @@ class combinations(Iterator[_T_co]):
301
499
  def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> combinations[tuple[_T, _T, _T, _T, _T]]: ...
302
500
  @overload
303
501
  def __new__(cls, iterable: Iterable[_T], r: int) -> combinations[tuple[_T, ...]]: ...
304
- def __iter__(self) -> Self: ...
305
- def __next__(self) -> _T_co: ...
502
+ def __iter__(self) -> Self:
503
+ """Implement iter(self)."""
504
+ ...
505
+ def __next__(self) -> _T_co:
506
+ """Implement next(self)."""
507
+ ...
306
508
 
307
509
  class combinations_with_replacement(Iterator[_T_co]):
510
+ """
511
+ Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.
512
+
513
+ combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC"
514
+ """
308
515
  @overload
309
516
  def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations_with_replacement[tuple[_T, _T]]: ...
310
517
  @overload
@@ -315,17 +522,49 @@ class combinations_with_replacement(Iterator[_T_co]):
315
522
  def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> combinations_with_replacement[tuple[_T, _T, _T, _T, _T]]: ...
316
523
  @overload
317
524
  def __new__(cls, iterable: Iterable[_T], r: int) -> combinations_with_replacement[tuple[_T, ...]]: ...
318
- def __iter__(self) -> Self: ...
319
- def __next__(self) -> _T_co: ...
525
+ def __iter__(self) -> Self:
526
+ """Implement iter(self)."""
527
+ ...
528
+ def __next__(self) -> _T_co:
529
+ """Implement next(self)."""
530
+ ...
320
531
 
321
532
  if sys.version_info >= (3, 10):
322
533
  class pairwise(Iterator[_T_co]):
534
+ """
535
+ Return an iterator of overlapping pairs taken from the input iterator.
536
+
537
+ s -> (s0,s1), (s1,s2), (s2, s3), ...
538
+ """
323
539
  def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ...
324
- def __iter__(self) -> Self: ...
325
- def __next__(self) -> _T_co: ...
540
+ def __iter__(self) -> Self:
541
+ """Implement iter(self)."""
542
+ ...
543
+ def __next__(self) -> _T_co:
544
+ """Implement next(self)."""
545
+ ...
326
546
 
327
547
  if sys.version_info >= (3, 12):
328
548
  class batched(Iterator[tuple[_T_co, ...]], Generic[_T_co]):
549
+ """
550
+ Batch data into tuples of length n. The last batch may be shorter than n.
551
+
552
+ Loops over the input iterable and accumulates data into tuples
553
+ up to size n. The input is consumed lazily, just enough to
554
+ fill a batch. The result is yielded as soon as a batch is full
555
+ or when the input iterable is exhausted.
556
+
557
+ >>> for batch in batched('ABCDEFG', 3):
558
+ ... print(batch)
559
+ ...
560
+ ('A', 'B', 'C')
561
+ ('D', 'E', 'F')
562
+ ('G',)
563
+ """
329
564
  def __new__(cls, iterable: Iterable[_T_co], n: int) -> Self: ...
330
- def __iter__(self) -> Self: ...
331
- def __next__(self) -> tuple[_T_co, ...]: ...
565
+ def __iter__(self) -> Self:
566
+ """Implement iter(self)."""
567
+ ...
568
+ def __next__(self) -> tuple[_T_co, ...]:
569
+ """Implement next(self)."""
570
+ ...
@@ -1,3 +1,33 @@
1
+ """
2
+ This module contains functions that can read and write Python values in
3
+ a binary format. The format is specific to Python, but independent of
4
+ machine architecture issues.
5
+
6
+ Not all Python object types are supported; in general, only objects
7
+ whose value is independent from a particular invocation of Python can be
8
+ written and read by this module. The following types are supported:
9
+ None, integers, floating point numbers, strings, bytes, bytearrays,
10
+ tuples, lists, sets, dictionaries, and code objects, where it
11
+ should be understood that tuples, lists and dictionaries are only
12
+ supported as long as the values contained therein are themselves
13
+ supported; and recursive lists and dictionaries should not be written
14
+ (they will cause infinite loops).
15
+
16
+ Variables:
17
+
18
+ version -- indicates the format that the module uses. Version 0 is the
19
+ historical format, version 1 shares interned strings and version 2
20
+ uses a binary format for floating point numbers.
21
+ Version 3 shares common object references (New in version 3.4).
22
+
23
+ Functions:
24
+
25
+ dump() -- write value to a file
26
+ load() -- read value from a file
27
+ dumps() -- marshal value as a bytes object
28
+ loads() -- read value from a bytes-like object
29
+ """
30
+
1
31
  import builtins
2
32
  import sys
3
33
  import types
@@ -35,7 +65,55 @@ if sys.version_info >= (3, 13):
35
65
  def loads(bytes: ReadableBuffer, /, *, allow_code: bool = True) -> Any: ...
36
66
 
37
67
  else:
38
- def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /) -> None: ...
39
- def load(file: SupportsRead[bytes], /) -> Any: ...
40
- def dumps(value: _Marshallable, version: int = 4, /) -> bytes: ...
41
- def loads(bytes: ReadableBuffer, /) -> Any: ...
68
+ def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /) -> None:
69
+ """
70
+ Write the value on the open file.
71
+
72
+ value
73
+ Must be a supported type.
74
+ file
75
+ Must be a writeable binary file.
76
+ version
77
+ Indicates the data format that dump should use.
78
+
79
+ If the value has (or contains an object that has) an unsupported type, a
80
+ ValueError exception is raised - but garbage data will also be written
81
+ to the file. The object will not be properly read back by load().
82
+ """
83
+ ...
84
+ def load(file: SupportsRead[bytes], /) -> Any:
85
+ """
86
+ Read one value from the open file and return it.
87
+
88
+ file
89
+ Must be readable binary file.
90
+
91
+ If no valid value is read (e.g. because the data has a different Python
92
+ version's incompatible marshal format), raise EOFError, ValueError or
93
+ TypeError.
94
+
95
+ Note: If an object containing an unsupported type was marshalled with
96
+ dump(), load() will substitute None for the unmarshallable type.
97
+ """
98
+ ...
99
+ def dumps(value: _Marshallable, version: int = 4, /) -> bytes:
100
+ """
101
+ Return the bytes object that would be written to a file by dump(value, file).
102
+
103
+ value
104
+ Must be a supported type.
105
+ version
106
+ Indicates the data format that dumps should use.
107
+
108
+ Raise a ValueError exception if value has (or contains an object that has) an
109
+ unsupported type.
110
+ """
111
+ ...
112
+ def loads(bytes: ReadableBuffer, /) -> Any:
113
+ """
114
+ Convert the bytes-like object to a value.
115
+
116
+ If no valid value is found, raise EOFError, ValueError or TypeError. Extra
117
+ bytes in the input are ignored.
118
+ """
119
+ ...