From ebdd8dae4b94327f83470ab6f72033fd81cb456f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 4 Mar 2019 17:25:19 +1000 Subject: [PATCH] tidy up unused imports --- anki/collection.py | 5 +++-- anki/consts.py | 1 - anki/decks.py | 3 ++- anki/exporting.py | 3 ++- anki/importing/anki2.py | 3 +-- anki/importing/apkg.py | 3 ++- anki/importing/csvfile.py | 1 - anki/media.py | 5 +++-- anki/models.py | 4 ++-- anki/storage.py | 4 +++- anki/sync.py | 4 +++- anki/tags.py | 3 ++- anki/utils.py | 1 - aqt/addcards.py | 2 +- aqt/browser.py | 6 +++--- aqt/deckbrowser.py | 4 ++-- aqt/deckconf.py | 2 +- aqt/downloader.py | 3 +-- aqt/editor.py | 7 +++---- aqt/exporting.py | 2 +- aqt/modelchooser.py | 1 - aqt/overview.py | 1 - aqt/pinnedmodules.py | 2 +- aqt/preferences.py | 3 +-- aqt/profiles.py | 5 ++--- aqt/qt.py | 3 ++- aqt/reviewer.py | 3 ++- aqt/sync.py | 2 -- aqt/webview.py | 4 ++-- tools/build_ui.sh | 2 +- 30 files changed, 46 insertions(+), 46 deletions(-) diff --git a/anki/collection.py b/anki/collection.py index 30f447b67..60ac01441 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -11,10 +11,11 @@ import stat import datetime import copy import traceback +import json from anki.lang import _, ngettext -from anki.utils import ids2str, fieldChecksum, stripHTML, \ - intTime, splitFields, joinFields, maxID, json, devMode, stripHTMLMedia +from anki.utils import ids2str, fieldChecksum, \ + intTime, splitFields, joinFields, maxID, devMode, stripHTMLMedia from anki.hooks import runFilter, runHook from anki.models import ModelManager from anki.media import MediaManager diff --git a/anki/consts.py b/anki/consts.py index 1ffb99f4c..dde15fe93 100644 --- a/anki/consts.py +++ b/anki/consts.py @@ -2,7 +2,6 @@ # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -import os from anki.lang import _ # whether new cards should be mixed with reviews, or shown first or last diff --git a/anki/decks.py b/anki/decks.py index ebb8b60e1..1eef926a1 100644 --- a/anki/decks.py +++ b/anki/decks.py @@ -4,8 +4,9 @@ import copy, operator import unicodedata +import json -from anki.utils import intTime, ids2str, json +from anki.utils import intTime, ids2str from anki.hooks import runHook from anki.consts import * from anki.lang import _ diff --git a/anki/exporting.py b/anki/exporting.py index 3b17177e8..fa1bdb2d9 100644 --- a/anki/exporting.py +++ b/anki/exporting.py @@ -3,9 +3,10 @@ # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import re, os, zipfile, shutil, unicodedata +import json from anki.lang import _ -from anki.utils import ids2str, splitFields, json, namedtmp +from anki.utils import ids2str, splitFields, namedtmp from anki.hooks import runHook from anki import Collection diff --git a/anki/importing/anki2.py b/anki/importing/anki2.py index 379bd0178..ce88c4b94 100644 --- a/anki/importing/anki2.py +++ b/anki/importing/anki2.py @@ -5,10 +5,9 @@ import os import unicodedata from anki import Collection -from anki.utils import intTime, splitFields, joinFields, incGuid +from anki.utils import intTime, splitFields, joinFields from anki.importing.base import Importer from anki.lang import _ -from anki.lang import ngettext GUID = 1 MID = 2 diff --git a/anki/importing/apkg.py b/anki/importing/apkg.py index 7b9f326f0..d6f02e56c 100644 --- a/anki/importing/apkg.py +++ b/anki/importing/apkg.py @@ -4,7 +4,8 @@ import zipfile, os import unicodedata -from anki.utils import tmpfile, json +import json +from anki.utils import tmpfile from anki.importing.anki2 import Anki2Importer class AnkiPackageImporter(Anki2Importer): diff --git a/anki/importing/csvfile.py b/anki/importing/csvfile.py index 59d1c838f..28ddef372 100644 --- a/anki/importing/csvfile.py +++ b/anki/importing/csvfile.py @@ -2,7 +2,6 @@ # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -import codecs import csv import re diff --git a/anki/media.py b/anki/media.py index e2df7536c..ff7f03e96 100644 --- a/anki/media.py +++ b/anki/media.py @@ -9,9 +9,10 @@ import unicodedata import sys import zipfile import pathlib -from io import StringIO +import json +import os -from anki.utils import checksum, isWin, isMac, json +from anki.utils import checksum, isWin, isMac from anki.db import DB, DBError from anki.consts import * from anki.latex import mungeQA diff --git a/anki/models.py b/anki/models.py index 54a10ccf9..b421554cf 100644 --- a/anki/models.py +++ b/anki/models.py @@ -2,9 +2,9 @@ # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -import copy, re +import copy, re, json from anki.utils import intTime, joinFields, splitFields, ids2str,\ - checksum, json + checksum from anki.lang import _ from anki.consts import * from anki.hooks import runHook diff --git a/anki/storage.py b/anki/storage.py index ab24caa0e..6375d6f1c 100644 --- a/anki/storage.py +++ b/anki/storage.py @@ -4,9 +4,11 @@ import copy import re +import json +import os from anki.lang import _ -from anki.utils import intTime, json, isWin +from anki.utils import intTime, isWin from anki.db import DB from anki.collection import _Collection from anki.consts import * diff --git a/anki/sync.py b/anki/sync.py index f44814a6d..f5d21e89d 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -6,9 +6,11 @@ import io import gzip import random import requests +import json +import os from anki.db import DB, DBError -from anki.utils import ids2str, intTime, json, platDesc, checksum, devMode +from anki.utils import ids2str, intTime, platDesc, checksum, devMode from anki.consts import * from anki.utils import versionWithBuild from .hooks import runHook diff --git a/anki/tags.py b/anki/tags.py index a8028d2c2..f9e1860ba 100644 --- a/anki/tags.py +++ b/anki/tags.py @@ -10,7 +10,8 @@ tracked, so unused tags can only be removed from the list with a DB check. This module manages the tag cache and tags for notes. """ -from anki.utils import intTime, ids2str, json +import json +from anki.utils import intTime, ids2str from anki.hooks import runHook import re diff --git a/anki/utils.py b/anki/utils.py index 271c960b7..726d1563f 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -17,7 +17,6 @@ import locale from hashlib import sha1 import platform import traceback -import json from contextlib import contextmanager from anki.lang import _, ngettext diff --git a/aqt/addcards.py b/aqt/addcards.py index 65c8d6f94..c00625c45 100644 --- a/aqt/addcards.py +++ b/aqt/addcards.py @@ -9,7 +9,7 @@ from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \ tooltip, openHelp, addCloseShortcut, downArrow from anki.sound import clearAudioQueue from anki.hooks import addHook, remHook, runHook -from anki.utils import stripHTMLMedia, htmlToTextLine, isMac +from anki.utils import htmlToTextLine, isMac import aqt.editor, aqt.modelchooser, aqt.deckchooser class AddCards(QDialog): diff --git a/aqt/browser.py b/aqt/browser.py index fd1eafa7c..5561e5d9a 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -14,9 +14,9 @@ import json from aqt.qt import * import anki import aqt.forms -from anki.utils import fmtTimeSpan, ids2str, stripHTMLMedia, htmlToTextLine, \ +from anki.utils import fmtTimeSpan, ids2str, htmlToTextLine, \ isWin, intTime, \ - isMac, isLin, bodyClass + isMac, bodyClass from aqt.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter, \ saveHeader, restoreHeader, saveState, restoreState, getTag, \ showInfo, askUser, tooltip, openHelp, showWarning, shortcut, mungeQA, \ @@ -25,7 +25,7 @@ from anki.lang import _ from anki.hooks import runHook, addHook, remHook, runFilter from aqt.webview import AnkiWebView from anki.consts import * -from anki.sound import playFromText, clearAudioQueue, allSounds, play +from anki.sound import clearAudioQueue, allSounds, play # Data model diff --git a/aqt/deckbrowser.py b/aqt/deckbrowser.py index 01bce24d0..1860efcc2 100644 --- a/aqt/deckbrowser.py +++ b/aqt/deckbrowser.py @@ -4,8 +4,8 @@ from aqt.qt import * from aqt.utils import askUser, getOnlyText, openLink, showWarning, shortcut, \ - openHelp, downArrow -from anki.utils import isMac, ids2str, fmtTimeSpan + openHelp +from anki.utils import ids2str, fmtTimeSpan from anki.errors import DeckRenameError import aqt from anki.sound import clearAudioQueue diff --git a/aqt/deckconf.py b/aqt/deckconf.py index a21c8392d..dcad9b971 100644 --- a/aqt/deckconf.py +++ b/aqt/deckconf.py @@ -7,7 +7,7 @@ from anki.consts import NEW_CARDS_RANDOM from aqt.qt import * import aqt from aqt.utils import showInfo, showWarning, openHelp, getOnlyText, askUser, \ - tooltip, saveGeom, restoreGeom, downArrow + tooltip, saveGeom, restoreGeom from anki.lang import _, ngettext class DeckConf(QDialog): diff --git a/aqt/downloader.py b/aqt/downloader.py index 7524674c5..37127bc10 100644 --- a/aqt/downloader.py +++ b/aqt/downloader.py @@ -2,10 +2,9 @@ # -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -import time, re, traceback +import time, re from aqt.qt import * from anki.sync import AnkiRequestsClient -from aqt.utils import showWarning from anki.hooks import addHook, remHook import aqt from anki.lang import _ diff --git a/aqt/editor.py b/aqt/editor.py index 3b5aa4633..612c99cbd 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -2,25 +2,24 @@ # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import re -import os -import ctypes import urllib.request, urllib.parse, urllib.error import warnings import html import mimetypes import base64 import unicodedata +import json from anki.lang import _ from aqt.qt import * -from anki.utils import stripHTML, isWin, isMac, namedtmp, json, stripHTMLMedia, \ +from anki.utils import isWin, namedtmp, stripHTMLMedia, \ checksum import anki.sound from anki.hooks import runHook, runFilter, addHook from aqt.sound import getAudio from aqt.webview import AnkiWebView from aqt.utils import shortcut, showInfo, showWarning, getFile, \ - openHelp, tooltip, downArrow, qtMenuShortcutWorkaround + openHelp, tooltip, qtMenuShortcutWorkaround import aqt from bs4 import BeautifulSoup import requests diff --git a/aqt/exporting.py b/aqt/exporting.py index f89dad174..32c7dc856 100644 --- a/aqt/exporting.py +++ b/aqt/exporting.py @@ -6,7 +6,7 @@ import re from aqt.qt import * import aqt -from aqt.utils import getSaveFile, tooltip, showWarning, askUser, \ +from aqt.utils import getSaveFile, tooltip, showWarning, \ checkInvalidFilename, showInfo from anki.exporting import exporters from anki.hooks import addHook, remHook diff --git a/aqt/modelchooser.py b/aqt/modelchooser.py index 2eb0d09b7..2eeae55cb 100644 --- a/aqt/modelchooser.py +++ b/aqt/modelchooser.py @@ -5,7 +5,6 @@ from aqt.qt import * from anki.hooks import addHook, remHook, runHook from aqt.utils import shortcut -import aqt from anki.lang import _ class ModelChooser(QHBoxLayout): diff --git a/aqt/overview.py b/aqt/overview.py index e4fe3e8b0..12c5cd6ae 100644 --- a/aqt/overview.py +++ b/aqt/overview.py @@ -3,7 +3,6 @@ # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from aqt.utils import openLink, shortcut, tooltip, askUserDialog -from anki.utils import isMac import aqt from anki.sound import clearAudioQueue from anki.lang import _ diff --git a/aqt/pinnedmodules.py b/aqt/pinnedmodules.py index b8d034b92..19091d3f4 100644 --- a/aqt/pinnedmodules.py +++ b/aqt/pinnedmodules.py @@ -4,7 +4,7 @@ # this file is imported as part of the bundling process to ensure certain # modules are included in the distribution -# pylint: disable=import-error +# pylint: disable=import-error,unused-import # required by requests library import queue diff --git a/aqt/preferences.py b/aqt/preferences.py index 29d9b195b..1b7e50dad 100644 --- a/aqt/preferences.py +++ b/aqt/preferences.py @@ -5,8 +5,7 @@ import datetime, time from aqt.qt import * import anki.lang -from aqt.utils import openFolder, showWarning, getText, openHelp, showInfo, \ - askUser +from aqt.utils import openFolder, openHelp, showInfo, askUser import aqt from anki.lang import _ diff --git a/aqt/profiles.py b/aqt/profiles.py index c99790f26..2a613591d 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -6,7 +6,6 @@ # - Saves in pickles rather than json to easily store Qt window state. # - Saves in sqlite rather than a flat file so the config can't be corrupted -import os import random import pickle import shutil @@ -16,7 +15,7 @@ import re from aqt.qt import * from anki.db import DB -from anki.utils import isMac, isWin, intTime, checksum +from anki.utils import isMac, isWin, intTime import anki.lang from aqt.utils import showWarning from aqt import appHelpSite @@ -136,7 +135,7 @@ a flash drive.""" % self.base) def find_class(self, module, name): if module == "PyQt5.sip": try: - import PyQt5.sip + import PyQt5.sip # pylint: disable=unused-import except: # use old sip location module = "sip" diff --git a/aqt/qt.py b/aqt/qt.py index 6eb2db004..29bc7785f 100644 --- a/aqt/qt.py +++ b/aqt/qt.py @@ -1,7 +1,8 @@ # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -# fixme: make sure not to optimize imports on this file +# make sure not to optimize imports on this file +# pylint: disable=unused-import import os diff --git a/aqt/reviewer.py b/aqt/reviewer.py index ca4dd8fce..f01fcbd9f 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -7,10 +7,11 @@ import re import html import unicodedata as ucd import html.parser +import json from anki.lang import _, ngettext from aqt.qt import * -from anki.utils import stripHTML, json, bodyClass +from anki.utils import stripHTML, bodyClass from anki.hooks import addHook, runHook, runFilter from anki.sound import playFromText, clearAudioQueue, play from aqt.utils import mungeQA, tooltip, askUserDialog, \ diff --git a/aqt/sync.py b/aqt/sync.py index 5299bb13a..1be967dd8 100644 --- a/aqt/sync.py +++ b/aqt/sync.py @@ -2,11 +2,9 @@ # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import time -import traceback import gc from aqt.qt import * -import aqt from anki import Collection from anki.sync import Syncer, RemoteServer, FullSyncer, MediaSyncer, \ RemoteMediaServer diff --git a/aqt/webview.py b/aqt/webview.py index ef255099b..ee99fb5bb 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -6,8 +6,8 @@ import sys import math from anki.hooks import runHook from aqt.qt import * -from aqt.utils import openLink, showWarning, tooltip -from anki.utils import isMac, isWin, isLin, devMode +from aqt.utils import openLink, tooltip +from anki.utils import isMac, isWin, isLin from anki.lang import _ # Page for debug messages diff --git a/tools/build_ui.sh b/tools/build_ui.sh index a8f44dabd..4de8ebc93 100755 --- a/tools/build_ui.sh +++ b/tools/build_ui.sh @@ -30,7 +30,7 @@ do pyuic5 --from-imports $i -o $py.tmp (cat < $py # -*- coding: utf-8 -*- -# pylint: disable=unsubscriptable-object +# pylint: disable=unsubscriptable-object,unused-import from anki.lang import _ EOF rm $py.tmp