Enable strict_optional for aqt/data, aqt/forms, aqt/import_export (#3489)

* Added spacing

* Enable strict_optional for aqt/data

* Update CONTRIBUTORS

* Enable strict_optional for aqt/forms

* Enable strict_optional for aqt/import_export

* Fix mypy errors in import_dialog.py

* Fix mypy errors in exporting.py

* Better variable name

* Stick to assert convention
This commit is contained in:
Ben Nguyen 2024-10-11 21:36:15 -07:00 committed by GitHub
parent eae9bbc473
commit aaf4994e6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 6 deletions

View file

@ -30,6 +30,12 @@ disallow_untyped_defs = False
strict_optional = True
[mypy-aqt.browser.*]
strict_optional = True
[mypy-aqt.data.*]
strict_optional = True
[mypy-aqt.forms.*]
strict_optional = True
[mypy-aqt.import_export.*]
strict_optional = True
[mypy-aqt.operations.*]
strict_optional = True
[mypy-anki.scheduler.base]
@ -41,10 +47,10 @@ disallow_untyped_defs = False
[mypy-stringcase]
ignore_missing_imports = True
[mypy-aqt.mpv]
disallow_untyped_defs=False
ignore_errors=True
disallow_untyped_defs = False
ignore_errors = True
[mypy-aqt.winpaths]
disallow_untyped_defs=False
disallow_untyped_defs = False
[mypy-win32file]
ignore_missing_imports = True

View file

@ -88,7 +88,9 @@ class ExportDialog(QDialog):
self.frm.includeHTML.setChecked(True)
# set default option if accessed through deck button
if did:
name = self.mw.col.decks.get(did)["name"]
deck = self.mw.col.decks.get(did)
assert deck is not None
name = deck["name"]
index = self.frm.deck.findText(name)
self.frm.deck.setCurrentIndex(index)
self.frm.includeSched.setChecked(False)

View file

@ -64,7 +64,7 @@ class ImportDialog(QDialog):
restoreGeom(self, self.args.title, default_size=self.DEFAULT_SIZE)
addCloseShortcut(self)
self.web = AnkiWebView(kind=self.args.kind)
self.web: AnkiWebView | None = AnkiWebView(kind=self.args.kind)
self.web.setVisible(False)
self.web.load_sveltekit_page(f"{self.args.ts_page}/{quote(self.args.path)}")
layout = QVBoxLayout()
@ -78,6 +78,7 @@ class ImportDialog(QDialog):
def reject(self) -> None:
if self.mw.col and self.windowModality() == Qt.WindowModality.ApplicationModal:
self.mw.col.set_wants_abort()
assert self.web is not None
self.web.cleanup()
self.web = None
saveGeom(self, self.args.title)