From d789cea384aa408e56ab2ce30f679a76e306717e Mon Sep 17 00:00:00 2001 From: Matt Krump <1036969+mkrump@users.noreply.github.com> Date: Tue, 28 Jul 2020 15:52:21 -0600 Subject: [PATCH 1/3] Fix svelte error * Fix error: Type '{ opacity: number; }' is not assignable to type 'string'. (ts) --- ts/src/stats/CardCounts.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/src/stats/CardCounts.svelte b/ts/src/stats/CardCounts.svelte index 3f4c065da..923286bec 100644 --- a/ts/src/stats/CardCounts.svelte +++ b/ts/src/stats/CardCounts.svelte @@ -36,7 +36,7 @@ + style="opacity: {graphData.totalCards ? 1 : 0};"> From 24e7156991d244f9fa10a558c009f0e9b6eceb52 Mon Sep 17 00:00:00 2001 From: Matt Krump <1036969+mkrump@users.noreply.github.com> Date: Tue, 28 Jul 2020 16:19:16 -0600 Subject: [PATCH 2/3] Turn on check_untyped_defs for aqt.editor * Turn on check_untyped_defs for aqt.browser * Add type hints --- qt/aqt/editor.py | 4 +++- qt/mypy.ini | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index e07060616..a367616b0 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -13,6 +13,7 @@ import urllib.request import warnings from typing import Callable, List, Optional, Tuple +import bs4 import requests from bs4 import BeautifulSoup @@ -859,7 +860,7 @@ to a cloze type first, via 'Notes>Change Note Type'""" removeTags = ["script", "iframe", "object", "style"] - def _pastePreFilter(self, html, internal): + def _pastePreFilter(self, html: str, internal: bool) -> str: # https://anki.tenderapp.com/discussions/ankidesktop/39543-anki-is-replacing-the-character-by-when-i-exit-the-html-edit-mode-ctrlshiftx if html.find(">") < 0: return html @@ -868,6 +869,7 @@ to a cloze type first, via 'Notes>Change Note Type'""" warnings.simplefilter("ignore", UserWarning) doc = BeautifulSoup(html, "html.parser") + tag: bs4.element.Tag if not internal: for tag in self.removeTags: for node in doc(tag): diff --git a/qt/mypy.ini b/qt/mypy.ini index 4d4b6a50a..8489500df 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -82,3 +82,5 @@ check_untyped_defs=true check_untyped_defs=true [mypy-aqt.browser] check_untyped_defs=true +[mypy-aqt.editor] +check_untyped_defs=true From 5e6f532f5690cb80586759f653b9679205d89b98 Mon Sep 17 00:00:00 2001 From: Matt Krump <1036969+mkrump@users.noreply.github.com> Date: Tue, 28 Jul 2020 16:52:39 -0600 Subject: [PATCH 3/3] Turn on check_untyped_defs for aqt.exporting --- pylib/anki/exporting.py | 5 +++++ qt/mypy.ini | 2 ++ 2 files changed, 7 insertions(+) diff --git a/pylib/anki/exporting.py b/pylib/anki/exporting.py index e5541bb53..b65ae58bc 100644 --- a/pylib/anki/exporting.py +++ b/pylib/anki/exporting.py @@ -19,6 +19,11 @@ from anki.utils import ids2str, namedtmp, splitFields, stripHTML class Exporter: includeHTML: Union[bool, None] = None + ext: Optional[str] = None + key: Optional[str] = None + includeTags: Optional[bool] = None + includeSched: Optional[bool] = None + includeMedia: Optional[bool] = None def __init__( self, diff --git a/qt/mypy.ini b/qt/mypy.ini index 8489500df..d5edf0d1c 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -84,3 +84,5 @@ check_untyped_defs=true check_untyped_defs=true [mypy-aqt.editor] check_untyped_defs=true +[mypy-aqt.exporting] +check_untyped_defs=true