jenkins-bot merged this change.
[IMPR] use setdefault in api._add_defaults
- use setdefault in api._add_defaults to simplify the code and
reduce code complexity
Change-Id: Ic8a436f36889ff8c10e987c09465d0b04678ba43
---
M pywikibot/data/api.py
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 8e9132b..a9f6d50 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1508,17 +1508,15 @@
# version number is at least 1.25wmf5 we add a dummy rawcontinue
# parameter. Querying siteinfo is save as it adds 'continue'.
if ('continue' not in self._params
- and 'rawcontinue' not in self._params
and self.site.mw_version >= '1.25wmf5'):
- self._params['rawcontinue'] = ['']
+ self._params.setdefault('rawcontinue', [''])
elif self.action == 'help' and self.site.mw_version > '1.24':
self._params['wrap'] = ['']
- if 'maxlag' not in self._params and config.maxlag:
- self._params['maxlag'] = [str(config.maxlag)]
- if 'format' not in self._params:
- self._params['format'] = ['json']
- elif self._params['format'] != ['json']:
+ if config.maxlag:
+ self._params.setdefault('maxlag', str(config.maxlag))
+ self._params.setdefault('format', ['json'])
+ if self._params['format'] != ['json']:
raise TypeError("Query format '%s' cannot be parsed."
% self._params['format'])
To view, visit change 567484. To unsubscribe, or for help writing mail filters, visit settings.