jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/926657 )
Change subject: [IMPR] Print an error message if a fixes entry is not a dict ......................................................................
[IMPR] Print an error message if a fixes entry is not a dict
If a fixes entry is different from a dict, throw an error message and print the fix entry to logfile if -debug option is given.
https://www.mediawiki.org/wiki/Topic:Xizzw3qpwgt24d62
Change-Id: I48134579d92d7dd5a5a9d329ca81b2e1191403b1 --- M scripts/replace.py 1 file changed, 24 insertions(+), 1 deletion(-)
Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py index feb6541..4cce7ab 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -883,7 +883,7 @@ return pagegenerators.MySQLPageGenerator(sql)
-def main(*args: str) -> None: +def main(*args: str) -> None: # noqa: C901 """ Process command line arguments and invoke bot.
@@ -1000,6 +1000,15 @@ pywikibot.info(f'The user fixes file could not be found: ' f'{fixes.filename}') return + + if not isinstance(fix, dict): + pywikibot.error( + f'fixes[{fix_name!r}] is a {type(fix).__name__}, not a dict') + if type(fix) is tuple: + pywikibot.info('Maybe a trailing comma in your user_fixes.py?') + pywikibot.debug(fix) + return + if not fix['replacements']: pywikibot.warning(f'No replacements defined for fix {fix_name!r}') continue
pywikibot-commits@lists.wikimedia.org