Enable strict_optional for aqt/importing.py (#3527)

* Enable strict_optional

* Fix mypy errors
This commit is contained in:
Ben Nguyen 2024-10-26 02:56:34 -07:00 committed by GitHub
parent 97b729c5d4
commit e4eaaa57ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -40,6 +40,8 @@ strict_optional = True
strict_optional = True
[mypy-aqt.editor]
strict_optional = True
[mypy-aqt.importing]
strict_optional = True
[mypy-aqt.preferences]
strict_optional = True
[mypy-anki.scheduler.base]

View file

@ -60,7 +60,7 @@ class ChangeMap(QDialog):
self.frm.fields.setCurrentRow(n + 1)
self.field: str | None = None
def getField(self) -> str:
def getField(self) -> str | None:
self.exec()
return self.field
@ -91,8 +91,10 @@ class ImportDialog(QDialog):
self.importer = importer
self.frm = aqt.forms.importing.Ui_ImportDialog()
self.frm.setupUi(self)
help_button = self.frm.buttonBox.button(QDialogButtonBox.StandardButton.Help)
assert help_button is not None
qconnect(
self.frm.buttonBox.button(QDialogButtonBox.StandardButton.Help).clicked,
help_button.clicked,
self.helpRequested,
)
disable_help_button(self)
@ -103,6 +105,7 @@ class ImportDialog(QDialog):
gui_hooks.current_note_type_did_change.append(self.modelChanged)
qconnect(self.frm.autoDetect.clicked, self.onDelimiter)
self.updateDelimiterButtonText()
assert self.mw.pm.profile is not None
self.frm.allowHTML.setChecked(self.mw.pm.profile.get("allowHTML", True))
qconnect(self.frm.importMode.currentIndexChanged, self.importModeChanged)
self.frm.importMode.setCurrentIndex(self.mw.pm.profile.get("importMode", 1))
@ -187,6 +190,7 @@ class ImportDialog(QDialog):
showWarning(tr.importing_the_first_field_of_the_note())
return
self.importer.importMode = self.frm.importMode.currentIndex()
assert self.mw.pm.profile is not None
self.mw.pm.profile["importMode"] = self.importer.importMode
self.importer.allowHTML = self.frm.allowHTML.isChecked()
self.mw.pm.profile["allowHTML"] = self.importer.allowHTML