Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688318
)
Change subject: Cleared Unnecessary else/elif used after raise
......................................................................
Cleared Unnecessary else/elif used after raise
Corrected the anti-pattern cited in..
https://deepsource.io/gh/xqt/pywikibot/issue/PYL-R1720/occurrences/
Bug: T277890
Change-Id: I0fd4c779c576c1b313162e46538f0855496ccff2
---
M pywikibot/data/api.py
M pywikibot/site/_interwikimap.py
2 files changed, 5 insertions(+), 8 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index dac4d9d..bedb97f 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -2178,8 +2178,7 @@
if 'action' in parameters and parameters['action'] !=
'query':
raise Error("{}: 'action' must be 'query', not {}"
.format(self.__class__.__name__, kwargs['action']))
- else:
- parameters['action'] = 'query'
+ parameters['action'] = 'query'
# make sure request type is valid, and get limit key if any
for modtype in ('generator', 'list', 'prop',
'meta'):
if modtype in parameters:
@@ -2424,9 +2423,8 @@
if self._check_result_namespace is NotImplemented:
raise TypeError('{} module does not support multiple '
'namespaces'.format(self.limited_module))
- else:
- self._namespaces = set(namespaces)
- namespaces = None
+ self._namespaces = set(namespaces)
+ namespaces = None
if namespaces:
self.request[self.prefix + 'namespace'] = namespaces
diff --git a/pywikibot/site/_interwikimap.py b/pywikibot/site/_interwikimap.py
index c9e2367..3737ded 100644
--- a/pywikibot/site/_interwikimap.py
+++ b/pywikibot/site/_interwikimap.py
@@ -76,9 +76,8 @@
return self._iw_sites[prefix]
if isinstance(self._iw_sites[prefix].site, Exception):
raise self._iw_sites[prefix].site
- else:
- raise TypeError('_iw_sites[{}] is wrong type: {}'
- .format(prefix, type(self._iw_sites[prefix].site)))
+ raise TypeError('_iw_sites[{}] is wrong type: {}'
+ .format(prefix, type(self._iw_sites[prefix].site)))
def get_by_url(self, url: str) -> Set[str]:
"""
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688318
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: I0fd4c779c576c1b313162e46538f0855496ccff2
Gerrit-Change-Number: 688318
Gerrit-PatchSet: 3
Gerrit-Owner: Sahilgrewalhere <sahilgrewalhere2001(a)outlook.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged