Turn on check_untyped_defs for aqt.editor

* Turn on check_untyped_defs for aqt.browser
* Add type hints
This commit is contained in:
Matt Krump 2020-07-28 16:19:16 -06:00
parent d789cea384
commit 24e7156991
2 changed files with 5 additions and 1 deletions

View file

@ -13,6 +13,7 @@ import urllib.request
import warnings import warnings
from typing import Callable, List, Optional, Tuple from typing import Callable, List, Optional, Tuple
import bs4
import requests import requests
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@ -859,7 +860,7 @@ to a cloze type first, via 'Notes>Change Note Type'"""
removeTags = ["script", "iframe", "object", "style"] 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 # 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: if html.find(">") < 0:
return html return html
@ -868,6 +869,7 @@ to a cloze type first, via 'Notes>Change Note Type'"""
warnings.simplefilter("ignore", UserWarning) warnings.simplefilter("ignore", UserWarning)
doc = BeautifulSoup(html, "html.parser") doc = BeautifulSoup(html, "html.parser")
tag: bs4.element.Tag
if not internal: if not internal:
for tag in self.removeTags: for tag in self.removeTags:
for node in doc(tag): for node in doc(tag):

View file

@ -82,3 +82,5 @@ check_untyped_defs=true
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.browser] [mypy-aqt.browser]
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.editor]
check_untyped_defs=true