mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
add a few hints to some commonly used code
and add the extra hints mypy wanted
This commit is contained in:
parent
2fcc78f218
commit
eee099c0b2
6 changed files with 22 additions and 10 deletions
|
@ -10,7 +10,9 @@ import tempfile
|
||||||
import builtins
|
import builtins
|
||||||
import locale
|
import locale
|
||||||
import gettext
|
import gettext
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from aqt.main import AnkiQt
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import anki.lang
|
import anki.lang
|
||||||
from anki.consts import HELP_SITE
|
from anki.consts import HELP_SITE
|
||||||
|
@ -24,7 +26,7 @@ appDonate="http://ankisrs.net/support/"
|
||||||
appShared="https://ankiweb.net/shared/"
|
appShared="https://ankiweb.net/shared/"
|
||||||
appUpdate="https://ankiweb.net/update/desktop"
|
appUpdate="https://ankiweb.net/update/desktop"
|
||||||
appHelpSite=HELP_SITE
|
appHelpSite=HELP_SITE
|
||||||
mw = None # set on init
|
mw: Optional[AnkiQt] = None # set on init
|
||||||
|
|
||||||
moduleDir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
moduleDir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
from anki.lang import _
|
from typing import List
|
||||||
|
|
||||||
|
from anki.lang import _
|
||||||
|
from aqt import AnkiQt
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import aqt.forms
|
import aqt.forms
|
||||||
from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \
|
from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \
|
||||||
|
@ -14,7 +16,7 @@ import aqt.editor, aqt.modelchooser, aqt.deckchooser
|
||||||
|
|
||||||
class AddCards(QDialog):
|
class AddCards(QDialog):
|
||||||
|
|
||||||
def __init__(self, mw):
|
def __init__(self, mw: AnkiQt):
|
||||||
QDialog.__init__(self, None, Qt.Window)
|
QDialog.__init__(self, None, Qt.Window)
|
||||||
mw.setupDialogGC(self)
|
mw.setupDialogGC(self)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
|
@ -27,7 +29,7 @@ class AddCards(QDialog):
|
||||||
self.setupEditor()
|
self.setupEditor()
|
||||||
self.setupButtons()
|
self.setupButtons()
|
||||||
self.onReset()
|
self.onReset()
|
||||||
self.history = []
|
self.history: List[int] = []
|
||||||
self.previousNote = None
|
self.previousNote = None
|
||||||
restoreGeom(self, "add")
|
restoreGeom(self, "add")
|
||||||
addHook('reset', self.onReset)
|
addHook('reset', self.onReset)
|
||||||
|
|
|
@ -11,6 +11,7 @@ from operator import itemgetter
|
||||||
from anki.lang import ngettext
|
from anki.lang import ngettext
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from aqt import AnkiQt
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import anki
|
import anki
|
||||||
import aqt.forms
|
import aqt.forms
|
||||||
|
@ -383,7 +384,7 @@ class StatusDelegate(QItemDelegate):
|
||||||
|
|
||||||
class Browser(QMainWindow):
|
class Browser(QMainWindow):
|
||||||
|
|
||||||
def __init__(self, mw):
|
def __init__(self, mw: AnkiQt):
|
||||||
QMainWindow.__init__(self, None, Qt.Window)
|
QMainWindow.__init__(self, None, Qt.Window)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.col = self.mw.col
|
self.col = self.mw.col
|
||||||
|
|
|
@ -11,6 +11,7 @@ import unicodedata
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
|
from aqt import AnkiQt
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from anki.utils import isWin, namedtmp, stripHTMLMedia, \
|
from anki.utils import isWin, namedtmp, stripHTMLMedia, \
|
||||||
checksum
|
checksum
|
||||||
|
@ -40,7 +41,7 @@ html { background: %s; }
|
||||||
|
|
||||||
# caller is responsible for resetting note on reset
|
# caller is responsible for resetting note on reset
|
||||||
class Editor:
|
class Editor:
|
||||||
def __init__(self, mw, widget, parentWindow, addMode=False):
|
def __init__(self, mw: AnkiQt, widget, parentWindow, addMode=False):
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self.parentWindow = parentWindow
|
self.parentWindow = parentWindow
|
||||||
|
|
|
@ -10,8 +10,9 @@ import time
|
||||||
import faulthandler
|
import faulthandler
|
||||||
import platform
|
import platform
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from typing import Optional
|
||||||
from send2trash import send2trash
|
from send2trash import send2trash
|
||||||
|
from anki.collection import _Collection
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from anki.storage import Collection
|
from anki.storage import Collection
|
||||||
from anki.utils import isWin, isMac, intTime, splitFields, ids2str, \
|
from anki.utils import isWin, isMac, intTime, splitFields, ids2str, \
|
||||||
|
@ -36,6 +37,7 @@ class AnkiQt(QMainWindow):
|
||||||
QMainWindow.__init__(self)
|
QMainWindow.__init__(self)
|
||||||
self.state = "startup"
|
self.state = "startup"
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
|
self.col: Optional[_Collection] = None
|
||||||
aqt.mw = self
|
aqt.mw = self
|
||||||
self.app = app
|
self.app = app
|
||||||
self.pm = profileManager
|
self.pm = profileManager
|
||||||
|
|
|
@ -9,7 +9,11 @@ import unicodedata as ucd
|
||||||
import html.parser
|
import html.parser
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from anki.cards import Card
|
||||||
from anki.lang import _, ngettext
|
from anki.lang import _, ngettext
|
||||||
|
from aqt import AnkiQt
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from anki.utils import stripHTML, bodyClass
|
from anki.utils import stripHTML, bodyClass
|
||||||
from anki.hooks import addHook, runHook, runFilter
|
from anki.hooks import addHook, runHook, runFilter
|
||||||
|
@ -23,13 +27,13 @@ import aqt
|
||||||
class Reviewer:
|
class Reviewer:
|
||||||
"Manage reviews. Maintains a separate state."
|
"Manage reviews. Maintains a separate state."
|
||||||
|
|
||||||
def __init__(self, mw):
|
def __init__(self, mw: AnkiQt):
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.web = mw.web
|
self.web = mw.web
|
||||||
self.card = None
|
self.card = None
|
||||||
self.cardQueue = []
|
self.cardQueue: List[Card] = []
|
||||||
self.hadCardQueue = False
|
self.hadCardQueue = False
|
||||||
self._answeredIds = []
|
self._answeredIds: List[int] = []
|
||||||
self._recordedAudio = None
|
self._recordedAudio = None
|
||||||
self.typeCorrect = None # web init happens before this is set
|
self.typeCorrect = None # web init happens before this is set
|
||||||
self.state = None
|
self.state = None
|
||||||
|
|
Loading…
Reference in a new issue