mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Merge pull request #711 from mkrump/help-wanted-4-add-type-hints-5
Turn on check_untyped_defs for aqt.editor and aqt.exporting
This commit is contained in:
commit
98679d6188
3 changed files with 12 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -82,3 +82,7 @@ check_untyped_defs=true
|
|||
check_untyped_defs=true
|
||||
[mypy-aqt.browser]
|
||||
check_untyped_defs=true
|
||||
[mypy-aqt.editor]
|
||||
check_untyped_defs=true
|
||||
[mypy-aqt.exporting]
|
||||
check_untyped_defs=true
|
||||
|
|
Loading…
Reference in a new issue