mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Enable strict_optional for aqt/studydeck, tts, mediasrv (#3542)
* Enable strict_optional for studydeck * Fix mypy errors * Enable strict_optional for tts * Fix mypy errors in tts * Enable strict_optional for mediasrv * Fix mypy errors in mediasrv
This commit is contained in:
parent
7f58ca213c
commit
a25edecc88
4 changed files with 16 additions and 3 deletions
|
@ -56,6 +56,12 @@ strict_optional = True
|
|||
strict_optional = True
|
||||
[mypy-aqt.deckbrowser]
|
||||
strict_optional = True
|
||||
[mypy-aqt.studydeck]
|
||||
strict_optional = True
|
||||
[mypy-aqt.tts]
|
||||
strict_optional = True
|
||||
[mypy-aqt.mediasrv]
|
||||
strict_optional = True
|
||||
[mypy-anki.scheduler.base]
|
||||
strict_optional = True
|
||||
[mypy-anki._backend.rsbridge]
|
||||
|
|
|
@ -735,8 +735,12 @@ def _extract_page_context() -> PageContext:
|
|||
return PageContext.NON_LEGACY_PAGE
|
||||
elif referer.path == "/_anki/legacyPageData":
|
||||
query_params = parse_qs(referer.query)
|
||||
id = int(query_params.get("id", [None])[0])
|
||||
return aqt.mw.mediaServer.get_page_context(id)
|
||||
query_id = query_params.get("id")
|
||||
if not query_id:
|
||||
return PageContext.UNKNOWN
|
||||
id = int(query_id[0])
|
||||
page_context = aqt.mw.mediaServer.get_page_context(id)
|
||||
return page_context if page_context else PageContext.UNKNOWN
|
||||
else:
|
||||
return PageContext.UNKNOWN
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class StudyDeck(QDialog):
|
|||
else:
|
||||
self.exec()
|
||||
|
||||
def eventFilter(self, obj: QObject, evt: QEvent) -> bool:
|
||||
def eventFilter(self, obj: QObject | None, evt: QEvent | None) -> bool:
|
||||
if isinstance(evt, QKeyEvent) and evt.type() == QEvent.Type.KeyPress:
|
||||
new_row = current_row = self.form.list.currentRow()
|
||||
rows_count = self.form.list.count()
|
||||
|
@ -178,6 +178,7 @@ class StudyDeck(QDialog):
|
|||
|
||||
def success(out: OpChangesWithId) -> None:
|
||||
deck = self.mw.col.decks.get(DeckId(out.id))
|
||||
assert deck is not None
|
||||
self.name = deck["name"]
|
||||
self.accept_with_callback()
|
||||
|
||||
|
|
|
@ -189,6 +189,7 @@ class MacTTSPlayer(TTSProcessPlayer):
|
|||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
# write the input text to stdin
|
||||
assert self._process.stdin is not None
|
||||
self._process.stdin.write(tag.field_text.encode("utf8"))
|
||||
self._process.stdin.close()
|
||||
self._wait_for_termination(tag)
|
||||
|
@ -247,6 +248,7 @@ class MacTTSFilePlayer(MacTTSPlayer):
|
|||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
# write the input text to stdin
|
||||
assert self._process.stdin is not None
|
||||
self._process.stdin.write(tag.field_text.encode("utf8"))
|
||||
self._process.stdin.close()
|
||||
self._wait_for_termination(tag)
|
||||
|
|
Loading…
Reference in a new issue