jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1007894?usp=email )
Change subject: [IMPR] Adopt error message from Python 3.13 for batched function ......................................................................
[IMPR] Adopt error message from Python 3.13 for batched function
Also add some doc tests
Change-Id: I97068d5dd664d125b53b870464ecb1fdc8bb4a65 --- M pywikibot/backports.py 1 file changed, 21 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/backports.py b/pywikibot/backports.py index e49e815..5286439 100644 --- a/pywikibot/backports.py +++ b/pywikibot/backports.py @@ -156,6 +156,14 @@ Traceback (most recent call last): ... StopIteration + >>> list(batched('ABCD', 2)) + [('A', 'B'), ('C', 'D')] + >>> list(batched('ABCD', 3, strict=False)) + [('A', 'B', 'C'), ('D',)] + >>> list(batched('ABCD', 3, strict=True)) + Traceback (most recent call last): + ... + ValueError: batched(): incomplete batch
.. seealso:: :python:`itertools.batched <library/itertools.html#itertools.batched>`, @@ -167,9 +175,9 @@ :param n: How many items of the iterable to get in one chunk :param strict: raise a ValueError if the final batch is shorter than *n*. - :raise ValueError: the final batch is shorter than *n*. + :raise ValueError: batched(): incomplete batch """ - msg = f'The final batch is shorter than n={n}' + msg = 'batched(): incomplete batch' if PYTHON_VERSION < (3, 12): group = [] for item in iterable:
pywikibot-commits@lists.wikimedia.org