jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1017485?usp=email )
Change subject: [bugfix] Fix TypeError in colors.py with backports.batched ...................................................................... [bugfix] Fix TypeError in colors.py with backports.batched Bug: T362035 Change-Id: I68d7a7c3451fce91e13385a57138c0ed50f26d64 Signed-off-by: Xqt <[email protected]> --- M pywikibot/backports.py M scripts/maintenance/colors.py 2 files changed, 19 insertions(+), 6 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/backports.py b/pywikibot/backports.py index 155effd..8b9d989 100644 --- a/pywikibot/backports.py +++ b/pywikibot/backports.py @@ -177,9 +177,13 @@ :param strict: raise a ValueError if the final batch is shorter than *n*. :raise ValueError: batched(): incomplete batch + :raise TypeError: *n* cannot be interpreted as an integer """ msg = 'batched(): incomplete batch' if PYTHON_VERSION < (3, 12): + if not isinstance(n, int): + raise TypeError(f'{type(n),__name__!r} object cannot be' + ' interpreted as an integer') group = [] for item in iterable: group.append(item) diff --git a/scripts/maintenance/colors.py b/scripts/maintenance/colors.py index bf73742..63c46a5 100755 --- a/scripts/maintenance/colors.py +++ b/scripts/maintenance/colors.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Utility to show pywikibot colors.""" # -# (C) Pywikibot team, 2016-2023 +# (C) Pywikibot team, 2016-2024 # # Distributed under the terms of the MIT license. # @@ -17,10 +17,8 @@ fg_colors = [col for col in colors if col != 'default'] bg_colors = fg_colors[:] n_fg_colors = len(fg_colors) - fg_colors.insert(3 * int(n_fg_colors / 4), 'default') - fg_colors.insert(2 * int(n_fg_colors / 4), 'default') - fg_colors.insert(int(n_fg_colors / 4), 'default') - fg_colors.insert(0, 'default') + for i in range(4): + fg_colors.insert((3 - i) * (n_fg_colors // 4), 'default') # Max len of color names for padding. max_len_fg_colors = len(max(fg_colors, key=len)) @@ -28,7 +26,7 @@ for bg_col in bg_colors: # Three lines per each backgoung color. - for fg_col_group in batched(fg_colors, n_fg_colors / 4 + 1): + for fg_col_group in batched(fg_colors, n_fg_colors // 4 + 1): line = '' for fg_col in fg_col_group: line += ' ' -- To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1017485?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I68d7a7c3451fce91e13385a57138c0ed50f26d64 Gerrit-Change-Number: 1017485 Gerrit-PatchSet: 8 Gerrit-Owner: Xqt <[email protected]> Gerrit-Reviewer: Meno25 <[email protected]> Gerrit-Reviewer: Xqt <[email protected]> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
_______________________________________________ Pywikibot-commits mailing list -- [email protected] To unsubscribe send an email to [email protected]
