mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
Merge branch 'master' into master
This commit is contained in:
commit
671b1c76cb
6 changed files with 25 additions and 12 deletions
|
@ -42,8 +42,8 @@ kenden
|
||||||
Nickolay Yudin <kelciour@gmail.com>
|
Nickolay Yudin <kelciour@gmail.com>
|
||||||
neitrinoweb <github.com/neitrinoweb/>
|
neitrinoweb <github.com/neitrinoweb/>
|
||||||
Andreas Reis <github.com/rathsky>
|
Andreas Reis <github.com/rathsky>
|
||||||
Alexander Presnyakov <flagist0@gmail.com>
|
|
||||||
Matt Krump <github.com/mkrump>
|
Matt Krump <github.com/mkrump>
|
||||||
|
Alexander Presnyakov <flagist0@gmail.com>
|
||||||
abdo <github.com/ANH25>
|
abdo <github.com/ANH25>
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
# 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 operator import itemgetter
|
from operator import itemgetter
|
||||||
from typing import Dict, Union
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import QLineEdit
|
||||||
|
|
||||||
import aqt
|
import aqt
|
||||||
from anki.consts import NEW_CARDS_RANDOM
|
from anki.consts import NEW_CARDS_RANDOM
|
||||||
|
@ -257,14 +259,14 @@ class DeckConf(QDialog):
|
||||||
# Saving
|
# Saving
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
def updateList(self, conf, key, w, minSize=1):
|
def updateList(self, conf: Any, key: str, w: QLineEdit, minSize: int = 1) -> None:
|
||||||
items = str(w.text()).split(" ")
|
items = str(w.text()).split(" ")
|
||||||
ret = []
|
ret = []
|
||||||
for i in items:
|
for item in items:
|
||||||
if not i:
|
if not item:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
i = float(i)
|
i = float(item)
|
||||||
assert i > 0
|
assert i > 0
|
||||||
if i == int(i):
|
if i == int(i):
|
||||||
i = int(i)
|
i = int(i)
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ErrorHandler(QObject):
|
||||||
def setTimer(self):
|
def setTimer(self):
|
||||||
# we can't create a timer from a different thread, so we post a
|
# we can't create a timer from a different thread, so we post a
|
||||||
# message to the object on the main thread
|
# message to the object on the main thread
|
||||||
self.errorTimer.emit()
|
self.errorTimer.emit() # type: ignore
|
||||||
|
|
||||||
def _setTimer(self):
|
def _setTimer(self):
|
||||||
if not self.timer:
|
if not self.timer:
|
||||||
|
|
|
@ -10,6 +10,7 @@ import traceback
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import zipfile
|
import zipfile
|
||||||
from concurrent.futures import Future
|
from concurrent.futures import Future
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import anki.importing as importing
|
import anki.importing as importing
|
||||||
import aqt.deckchooser
|
import aqt.deckchooser
|
||||||
|
@ -55,7 +56,7 @@ class ChangeMap(QDialog):
|
||||||
self.frm.fields.setCurrentRow(n)
|
self.frm.fields.setCurrentRow(n)
|
||||||
else:
|
else:
|
||||||
self.frm.fields.setCurrentRow(n + 1)
|
self.frm.fields.setCurrentRow(n + 1)
|
||||||
self.field = None
|
self.field: Optional[str] = None
|
||||||
|
|
||||||
def getField(self):
|
def getField(self):
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
@ -488,7 +489,9 @@ def _replaceWithApkg(mw, filename, backup):
|
||||||
colname = "collection.anki2"
|
colname = "collection.anki2"
|
||||||
|
|
||||||
with z.open(colname) as source, open(mw.pm.collectionPath(), "wb") as target:
|
with z.open(colname) as source, open(mw.pm.collectionPath(), "wb") as target:
|
||||||
shutil.copyfileobj(source, target)
|
# ignore appears related to https://github.com/python/typeshed/issues/4349
|
||||||
|
# see if can turn off once issue fix is merged in
|
||||||
|
shutil.copyfileobj(source, target) # type: ignore
|
||||||
|
|
||||||
d = os.path.join(mw.pm.profileFolder(), "collection.media")
|
d = os.path.join(mw.pm.profileFolder(), "collection.media")
|
||||||
for n, (cStr, file) in enumerate(
|
for n, (cStr, file) in enumerate(
|
||||||
|
|
|
@ -6,6 +6,7 @@ from typing import List, Optional
|
||||||
|
|
||||||
import aqt.clayout
|
import aqt.clayout
|
||||||
from anki import stdmodels
|
from anki import stdmodels
|
||||||
|
from anki.backend_pb2 import NoteTypeNameIDUseCount
|
||||||
from anki.lang import _, ngettext
|
from anki.lang import _, ngettext
|
||||||
from anki.models import NoteType
|
from anki.models import NoteType
|
||||||
from anki.notes import Note
|
from anki.notes import Note
|
||||||
|
@ -88,7 +89,7 @@ class Models(QDialog):
|
||||||
|
|
||||||
self.mw.taskman.with_progress(save, on_done, self)
|
self.mw.taskman.with_progress(save, on_done, self)
|
||||||
|
|
||||||
def updateModelsList(self, notetypes):
|
def updateModelsList(self, notetypes: List[NoteTypeNameIDUseCount]) -> None:
|
||||||
row = self.form.modelsList.currentRow()
|
row = self.form.modelsList.currentRow()
|
||||||
if row == -1:
|
if row == -1:
|
||||||
row = 0
|
row = 0
|
||||||
|
@ -96,8 +97,7 @@ class Models(QDialog):
|
||||||
|
|
||||||
self.models = notetypes
|
self.models = notetypes
|
||||||
for m in self.models:
|
for m in self.models:
|
||||||
mUse = m.use_count
|
mUse = ngettext("%d note", "%d notes", m.use_count) % m.use_count
|
||||||
mUse = ngettext("%d note", "%d notes", mUse) % mUse
|
|
||||||
item = QListWidgetItem("%s [%s]" % (m.name, mUse))
|
item = QListWidgetItem("%s [%s]" % (m.name, mUse))
|
||||||
self.form.modelsList.addItem(item)
|
self.form.modelsList.addItem(item)
|
||||||
self.form.modelsList.setCurrentRow(row)
|
self.form.modelsList.setCurrentRow(row)
|
||||||
|
|
|
@ -68,3 +68,11 @@ check_untyped_defs=true
|
||||||
check_untyped_defs=true
|
check_untyped_defs=true
|
||||||
[mypy-aqt.dyndeckconf]
|
[mypy-aqt.dyndeckconf]
|
||||||
check_untyped_defs=true
|
check_untyped_defs=true
|
||||||
|
[mypy-aqt.models]
|
||||||
|
check_untyped_defs=true
|
||||||
|
[mypy-aqt.errors]
|
||||||
|
check_untyped_defs=true
|
||||||
|
[mypy-aqt.importing]
|
||||||
|
check_untyped_defs=true
|
||||||
|
[mypy-aqt.deckconf]
|
||||||
|
check_untyped_defs=true
|
||||||
|
|
Loading…
Reference in a new issue