jenkins-bot has submitted this change and it was merged.
Change subject: Last flakes ......................................................................
Last flakes
Remove unused imports, globals, and make __all__ unmutable.
Change-Id: Ifc6f1baf1162855fda18fa0198fcd74515c0d2bc --- M generate_family_file.py M pwb.py M pywikibot/__init__.py M pywikibot/compat/catlib.py M pywikibot/compat/userlib.py M pywikibot/userinterfaces/terminal_interface.py M scripts/disambredir.py M scripts/maintenance/cache.py M tests/api_tests.py 9 files changed, 17 insertions(+), 15 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/generate_family_file.py b/generate_family_file.py index dfcdaf0..fd5aa0d 100644 --- a/generate_family_file.py +++ b/generate_family_file.py @@ -18,7 +18,6 @@ # system imports import sys import re -import os import codecs from collections import defaultdict from distutils.version import LooseVersion as V @@ -28,11 +27,11 @@
# creating & retrieving urls if sys.version_info[0] == 2: - from urlparse import urlparse, urljoin, ParseResult + from urlparse import urlparse, urljoin import urllib2 from urllib2 import HTTPError else: - from urllib.parse import urlparse, urljoin, ParseResult + from urllib.parse import urlparse, urljoin from urllib.error import HTTPError import urllib.request as urllib2
diff --git a/pwb.py b/pwb.py index 31a585a..0423435 100644 --- a/pwb.py +++ b/pwb.py @@ -20,6 +20,8 @@ import os import sys
+pwb = None +
def tryimport_pwb(): # See if we can import pywikibot. If so, we need to patch pwb.argvu, too. @@ -125,9 +127,12 @@ "Try running 'git submodule update --init'.") sys.exit(1)
+del httplib2 + if sys.version_info[0] == 2 and sys.version_info[1] == 6: try: import ordereddict + del ordereddict except ImportError as e: print("ImportError: %s" % e) print("pywikibot depends on module ordereddict in Python 2.6.") diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index b434615..e29691f 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -53,7 +53,7 @@ from pywikibot.tools import UnicodeMixin from pywikibot.i18n import translate
-__all__ = [ +__all__ = ( 'config', 'ui', 'UnicodeMixin', 'translate', 'Page', 'ImagePage', 'Category', 'Link', 'User', 'ItemPage', 'PropertyPage', 'Claim', 'TimeStripper', @@ -75,7 +75,7 @@ 'getCategoryLinks', 'categoryFormat', 'replaceCategoryLinks', 'removeCategoryLinks', 'removeCategoryLinksAndSeparator', 'replaceCategoryInPlace', 'compileLinkR', 'extract_templates_and_params', -] +)
class Timestamp(datetime.datetime): diff --git a/pywikibot/compat/catlib.py b/pywikibot/compat/catlib.py index 27940ff..985f6af 100644 --- a/pywikibot/compat/catlib.py +++ b/pywikibot/compat/catlib.py @@ -21,4 +21,4 @@ inPlace=True): return article.change_category(oldCat, newCat, comment, sortKey, inPlace)
-__all__ = ['Category', 'change_category'] +__all__ = ('Category', 'change_category',) diff --git a/pywikibot/compat/userlib.py b/pywikibot/compat/userlib.py index 348b059..7150992 100644 --- a/pywikibot/compat/userlib.py +++ b/pywikibot/compat/userlib.py @@ -16,4 +16,4 @@
from pywikibot import User
-__all__ = ['User'] +__all__ = ('User',) diff --git a/pywikibot/userinterfaces/terminal_interface.py b/pywikibot/userinterfaces/terminal_interface.py index 6805138..a58b3f5 100644 --- a/pywikibot/userinterfaces/terminal_interface.py +++ b/pywikibot/userinterfaces/terminal_interface.py @@ -13,4 +13,4 @@ else: from .terminal_interface_unix import UnixUI as UI
-__all__ = ['UI'] +__all__ = ('UI',) diff --git a/scripts/disambredir.py b/scripts/disambredir.py index a402a44..8038993 100644 --- a/scripts/disambredir.py +++ b/scripts/disambredir.py @@ -56,7 +56,7 @@ if m.group('title') == '' or mysite.isInterwikiLink(m.group('title')): continue else: - actualLinkPage = pywikibot.Page(page.site, m.group('title')) + actualLinkPage = pywikibot.Page(mysite, m.group('title')) # Check whether the link found is to page. if actualLinkPage != linkedPage: continue @@ -139,12 +139,11 @@ continue text = treat(text, page2, target) if text != page.get(): - comment = i18n.translate(mysite, msg, fallback=True) + comment = i18n.translate(page.site, msg, fallback=True) page.put(text, comment)
def main(): - global mysite, linktrail, page start = [] for arg in pywikibot.handleArgs(): start.append(arg) @@ -153,7 +152,6 @@ else: start = "!" mysite = pywikibot.Site() - linktrail = mysite.linktrail() try: generator = pagegenerators.CategorizedPageGenerator( mysite.disambcategory(), start=start) diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py index 2c51070..c97ce54 100644 --- a/scripts/maintenance/cache.py +++ b/scripts/maintenance/cache.py @@ -53,8 +53,8 @@ import pywikibot from pywikibot.data import api
-from pywikibot.site import APISite, DataSite, LoginStatus # noqa -from pywikibot.page import User # noqa +from pywikibot.site import APISite, DataSite, LoginStatus # flake8: noqa +from pywikibot.page import User # flake8: noqa
class ParseError(Exception): diff --git a/tests/api_tests.py b/tests/api_tests.py index 8bf9e1a..5faec1f 100644 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -10,7 +10,7 @@ import pywikibot import pywikibot.data.api as api from tests.utils import unittest -from tests.utils import SiteTestCase, NoSiteTestCase, CachedTestCase +from tests.utils import SiteTestCase, CachedTestCase
mysite = pywikibot.Site('en', 'wikipedia')
pywikibot-commits@lists.wikimedia.org