mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12: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 locale
|
||||
import gettext
|
||||
from typing import Optional
|
||||
|
||||
from aqt.main import AnkiQt
|
||||
from aqt.qt import *
|
||||
import anki.lang
|
||||
from anki.consts import HELP_SITE
|
||||
|
@ -24,7 +26,7 @@ appDonate="http://ankisrs.net/support/"
|
|||
appShared="https://ankiweb.net/shared/"
|
||||
appUpdate="https://ankiweb.net/update/desktop"
|
||||
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]
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# Copyright: Ankitects Pty Ltd and contributors
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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 *
|
||||
import aqt.forms
|
||||
from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \
|
||||
|
@ -14,7 +16,7 @@ import aqt.editor, aqt.modelchooser, aqt.deckchooser
|
|||
|
||||
class AddCards(QDialog):
|
||||
|
||||
def __init__(self, mw):
|
||||
def __init__(self, mw: AnkiQt):
|
||||
QDialog.__init__(self, None, Qt.Window)
|
||||
mw.setupDialogGC(self)
|
||||
self.mw = mw
|
||||
|
@ -27,7 +29,7 @@ class AddCards(QDialog):
|
|||
self.setupEditor()
|
||||
self.setupButtons()
|
||||
self.onReset()
|
||||
self.history = []
|
||||
self.history: List[int] = []
|
||||
self.previousNote = None
|
||||
restoreGeom(self, "add")
|
||||
addHook('reset', self.onReset)
|
||||
|
|
|
@ -11,6 +11,7 @@ from operator import itemgetter
|
|||
from anki.lang import ngettext
|
||||
import json
|
||||
|
||||
from aqt import AnkiQt
|
||||
from aqt.qt import *
|
||||
import anki
|
||||
import aqt.forms
|
||||
|
@ -383,7 +384,7 @@ class StatusDelegate(QItemDelegate):
|
|||
|
||||
class Browser(QMainWindow):
|
||||
|
||||
def __init__(self, mw):
|
||||
def __init__(self, mw: AnkiQt):
|
||||
QMainWindow.__init__(self, None, Qt.Window)
|
||||
self.mw = mw
|
||||
self.col = self.mw.col
|
||||
|
|
|
@ -11,6 +11,7 @@ import unicodedata
|
|||
import json
|
||||
|
||||
from anki.lang import _
|
||||
from aqt import AnkiQt
|
||||
from aqt.qt import *
|
||||
from anki.utils import isWin, namedtmp, stripHTMLMedia, \
|
||||
checksum
|
||||
|
@ -40,7 +41,7 @@ html { background: %s; }
|
|||
|
||||
# caller is responsible for resetting note on reset
|
||||
class Editor:
|
||||
def __init__(self, mw, widget, parentWindow, addMode=False):
|
||||
def __init__(self, mw: AnkiQt, widget, parentWindow, addMode=False):
|
||||
self.mw = mw
|
||||
self.widget = widget
|
||||
self.parentWindow = parentWindow
|
||||
|
|
|
@ -10,8 +10,9 @@ import time
|
|||
import faulthandler
|
||||
import platform
|
||||
from threading import Thread
|
||||
|
||||
from typing import Optional
|
||||
from send2trash import send2trash
|
||||
from anki.collection import _Collection
|
||||
from aqt.qt import *
|
||||
from anki.storage import Collection
|
||||
from anki.utils import isWin, isMac, intTime, splitFields, ids2str, \
|
||||
|
@ -36,6 +37,7 @@ class AnkiQt(QMainWindow):
|
|||
QMainWindow.__init__(self)
|
||||
self.state = "startup"
|
||||
self.opts = opts
|
||||
self.col: Optional[_Collection] = None
|
||||
aqt.mw = self
|
||||
self.app = app
|
||||
self.pm = profileManager
|
||||
|
|
|
@ -9,7 +9,11 @@ import unicodedata as ucd
|
|||
import html.parser
|
||||
import json
|
||||
|
||||
from typing import List
|
||||
|
||||
from anki.cards import Card
|
||||
from anki.lang import _, ngettext
|
||||
from aqt import AnkiQt
|
||||
from aqt.qt import *
|
||||
from anki.utils import stripHTML, bodyClass
|
||||
from anki.hooks import addHook, runHook, runFilter
|
||||
|
@ -23,13 +27,13 @@ import aqt
|
|||
class Reviewer:
|
||||
"Manage reviews. Maintains a separate state."
|
||||
|
||||
def __init__(self, mw):
|
||||
def __init__(self, mw: AnkiQt):
|
||||
self.mw = mw
|
||||
self.web = mw.web
|
||||
self.card = None
|
||||
self.cardQueue = []
|
||||
self.cardQueue: List[Card] = []
|
||||
self.hadCardQueue = False
|
||||
self._answeredIds = []
|
||||
self._answeredIds: List[int] = []
|
||||
self._recordedAudio = None
|
||||
self.typeCorrect = None # web init happens before this is set
|
||||
self.state = None
|
||||
|
|
Loading…
Reference in a new issue