jenkins-bot submitted this change.

View Change

Approvals: Zhuyifei1999: Looks good to me, approved jenkins-bot: Verified
[cleanup] return request.submit() directly

- A lot of methods assign request.submit() to a data variable
and return data. Now just return request.submit() directly
as data is not used elsewhere.
- Remove non-useful comments
- return None as default in image_repository()

Change-Id: I3c5bef5b7b4c88f99ef1909a4c89032095267304
---
M pywikibot/site/__init__.py
1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index 5ee61be..698e8b8 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -2799,6 +2799,8 @@
if bool(code or fam):
return pywikibot.Site(code, fam, self.username())

+ return None
+
def data_repository(self):
"""
Return the data repository connected to this site.
@@ -7907,7 +7909,6 @@

return wbdata['entities'][ids]
else:
- # not implemented yet
raise NotImplementedError

def data_repository(self):
@@ -7927,7 +7928,7 @@
url = self.siteinfo['general'].get('wikibase-geoshapestoragebaseurl')
if url:
return pywikibot.Site(url=url, user=self.username())
- # todo: should this raise?
+
return None

def tabular_data_repository(self):
@@ -7936,7 +7937,7 @@
'wikibase-tabulardatastoragebaseurl')
if url:
return pywikibot.Site(url=url, user=self.username())
- # todo: should this raise?
+
return None

def loadcontent(self, identification, *props):
@@ -8089,8 +8090,7 @@

params['data'] = json.dumps(data)
req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def addClaim(self, entity, claim, bot=True, summary=None):
@@ -8152,8 +8152,7 @@

params['baserevid'] = claim.on_item.latest_revision_id
req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def save_claim(self, claim, summary=None, bot=True):
@@ -8237,8 +8236,7 @@
params['snaks'] = json.dumps(snak)

req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def editQualifier(self, claim, qualifier, new=False, bot=True,
@@ -8275,8 +8273,7 @@
params['property'] = qualifier.getID()

req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def removeClaims(self, claims, bot=True, summary=None, baserevid=None):
@@ -8309,8 +8306,7 @@
}

req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def removeSources(self, claim, sources,
@@ -8340,8 +8336,7 @@
}

req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def remove_qualifiers(self, claim, qualifiers,
@@ -8372,8 +8367,7 @@
}

req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def linkTitles(self, page1, page2, bot=True):
@@ -8400,8 +8394,7 @@
if bot:
params['bot'] = 1
req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('item-merge')
@deprecated_args(ignoreconflicts='ignore_conflicts', fromItem='from_item',
@@ -8437,8 +8430,7 @@
if bot:
params['bot'] = 1
req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('item-redirect')
def set_redirect_target(self, from_item, to_item, bot=True):
@@ -8460,8 +8452,7 @@
'bot': bot,
}
req = self._simple_request(**params)
- data = req.submit()
- return data
+ return req.submit()

@need_right('edit')
def createNewItemFromPage(self, page, bot=True, **kwargs):

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3c5bef5b7b4c88f99ef1909a4c89032095267304
Gerrit-Change-Number: 606440
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-MessageType: merged