jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/567484 )

Change subject: [IMPR] use setdefault in api._add_defaults
......................................................................

[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(-)

Approvals:
  Dvorapa: Looks good to me, approved
  jenkins-bot: Verified



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 https://gerrit.wikimedia.org/r/567484
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic8a436f36889ff8c10e987c09465d0b04678ba43
Gerrit-Change-Number: 567484
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to