jenkins-bot submitted this change.

View Change


Approvals: Xqt: Looks good to me, approved Hashar: Looks good to me, approved jenkins-bot: Verified
[bugfix] Add missing f for ValueError in textlib._get_regexes

Also decrease nested flow statements

Change-Id: I6d75ae4fb76fc068761fd753af0ac6818c5a6b7b
---
M pywikibot/textlib.py
1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 047628b..2ed436e 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -319,26 +319,24 @@

# assume the string is a reference to a standard regex above,
# which may not yet have a site specific re compiled.
- if exc in _regex_cache:
- if isinstance(_regex_cache[exc], tuple):
- if not site and exc in ('interwiki', 'property', 'invoke',
- 'category', 'file'):
- raise ValueError(
- 'Site cannot be None for the {exc!r} regex')
-
- if (exc, site) not in _regex_cache:
- re_text, re_var = _regex_cache[exc]
- _regex_cache[(exc, site)] = re.compile(
- re_text % re_var(site), re.VERBOSE)
-
- result.append(_regex_cache[(exc, site)])
- else:
- result.append(_regex_cache[exc])
- else:
+ if exc not in _regex_cache:
# nowiki, noinclude, includeonly, timeline, math and other
# extensions
_regex_cache[exc] = _tag_regex(exc)
result.append(_regex_cache[exc])
+ elif not isinstance(_regex_cache[exc], tuple):
+ result.append(_regex_cache[exc])
+ else:
+ if not site and exc in ('interwiki', 'property', 'invoke',
+ 'category', 'file'):
+ raise ValueError(f'Site cannot be None for the {exc!r} regex')
+
+ if (exc, site) not in _regex_cache:
+ re_text, re_var = _regex_cache[exc]
+ _regex_cache[(exc, site)] = re.compile(
+ re_text % re_var(site), re.VERBOSE)
+
+ result.append(_regex_cache[(exc, site)])

# handle aliases
if exc == 'source':

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6d75ae4fb76fc068761fd753af0ac6818c5a6b7b
Gerrit-Change-Number: 920307
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Hashar <hashar@free.fr>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged