jenkins-bot submitted this change.

View Change


Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
[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(-)

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

To view, visit change 926657. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I48134579d92d7dd5a5a9d329ca81b2e1191403b1
Gerrit-Change-Number: 926657
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged