Skip to content

Commit

Permalink
[flake8] solve some flake8 issues
Browse files Browse the repository at this point in the history
Change-Id: Icf7ae49daa4d8ff874de419abdf07535d9b6174e
  • Loading branch information
xqt committed Jan 21, 2024
1 parent 1da09ee commit 68fac4e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
8 changes: 3 additions & 5 deletions pywikibot/page/_user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Object representing a Wiki user."""
#
# (C) Pywikibot team, 2009-2022
# (C) Pywikibot team, 2009-2024
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -261,10 +261,8 @@ def send_email(self, subject: str, text: str, ccme: bool = False) -> bool:
mailrequest = self.site.simple_request(**params)
maildata = mailrequest.submit()

if 'emailuser' in maildata \
and maildata['emailuser']['result'] == 'Success':
return True
return False
return ('emailuser' in maildata
and maildata['emailuser']['result'] == 'Success')

def block(self, *args, **kwargs):
"""
Expand Down
4 changes: 2 additions & 2 deletions pywikibot/site/_apisite.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Objects representing API interface to MediaWiki site."""
#
# (C) Pywikibot team, 2008-2023
# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -1280,7 +1280,7 @@ def has_data_repository(self) -> bool:
def image_repository(self) -> BaseSite | None:
"""Return Site object for image repository e.g. commons."""
code, fam = self.shared_image_repository()
if bool(code or fam):
if code or fam:
return pywikibot.Site(code, fam, self.username())

return None
Expand Down
4 changes: 2 additions & 2 deletions pywikibot/site/_siteinfo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Objects representing site info data contents."""
#
# (C) Pywikibot team, 2008-2023
# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -82,7 +82,7 @@ def _post_process(prop, data) -> None:
if prop in ('namespaces', 'magicwords'):
for index, value in enumerate(data):
# namespaces uses a dict, while magicwords uses a list
key = index if type(data) is list else value
key = index if isinstance(data, list) else value
for p in Siteinfo.BOOLEAN_PROPS[prop]:
data[key][p] = p in data[key]
else:
Expand Down
4 changes: 2 additions & 2 deletions scripts/maintenance/unidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.. versionadded:: 8.4
"""
#
# (C) Pywikibot team, 2018-2023
# (C) Pywikibot team, 2018-2024
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -38,7 +38,7 @@ def chars_uppers_wikilinks():
chars = []
uppers = []
wikilinks = ''
for i in range(0, maxunicode + 1):
for i in range(maxunicode + 1):
c = chr(i)
uc = c.upper()
if uc != c:
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations

import os
import re
import sys
Expand Down Expand Up @@ -57,6 +59,8 @@
'flake8-bugbear>=23.3.12',
'flake8-comprehensions>=3.13.0',
'flake8-docstrings>=1.4.0',
'flake8-executable',
'flake8-future-annotations',
'flake8-mock-x2',
'flake8-print>=5.0.0',
'flake8-quotes>=3.3.2',
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def version(self):
def image_repository(self):
"""Return Site object for image repository e.g. commons."""
code, fam = self.shared_image_repository()
if bool(code or fam):
if code or fam:
return pywikibot.Site(code, fam, self.username(),
interface=self.__class__)
return None
Expand All @@ -411,7 +411,7 @@ def data_repository(self):
'wikivoyage'):
code, fam = None, None

if bool(code or fam):
if code or fam:
return pywikibot.Site(code, fam, self.username(),
interface=DryDataSite)
return None
Expand Down

0 comments on commit 68fac4e

Please sign in to comment.