mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-18 09:55:59 +08:00
Bleach stubs: fix typos, use protocol classes (#2957)
This commit is contained in:
committed by
Sebastian Rittau
parent
e45f443d85
commit
e0b3cdd6fc
15
third_party/2and3/bleach/__init__.pyi
vendored
15
third_party/2and3/bleach/__init__.pyi
vendored
@@ -1,4 +1,4 @@
|
||||
from typing import List, Any, Optional, Text
|
||||
from typing import Any, Container, Iterable, Optional, Text
|
||||
|
||||
from bleach.linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker
|
||||
from bleach.sanitizer import (
|
||||
@@ -6,7 +6,7 @@ from bleach.sanitizer import (
|
||||
ALLOWED_PROTOCOLS as ALLOWED_PROTOCOLS,
|
||||
ALLOWED_STYLES as ALLOWED_STYLES,
|
||||
ALLOWED_TAGS as ALLOWED_TAGS,
|
||||
Cleaner as Clear,
|
||||
Cleaner as Cleaner,
|
||||
)
|
||||
|
||||
from .linkifier import _Callback
|
||||
@@ -17,13 +17,16 @@ VERSION: Any # packaging.version.Version
|
||||
|
||||
def clean(
|
||||
text: Text,
|
||||
tags: List[Text] = ...,
|
||||
tags: Container[Text] = ...,
|
||||
attributes: Any = ...,
|
||||
styles: List[Text] = ...,
|
||||
protocols: List[Text] = ...,
|
||||
styles: Container[Text] = ...,
|
||||
protocols: Container[Text] = ...,
|
||||
strip: bool = ...,
|
||||
strip_comments: bool = ...,
|
||||
) -> Text: ...
|
||||
def linkify(
|
||||
text: Text, callbacks: List[_Callback] = ..., skip_tags: Optional[List[Text]] = ..., parse_email: bool = ...
|
||||
text: Text,
|
||||
callbacks: Iterable[_Callback] = ...,
|
||||
skip_tags: Optional[Container[Text]] = ...,
|
||||
parse_email: bool = ...,
|
||||
) -> Text: ...
|
||||
|
||||
9
third_party/2and3/bleach/linkifier.pyi
vendored
9
third_party/2and3/bleach/linkifier.pyi
vendored
@@ -1,4 +1,4 @@
|
||||
from typing import Any, List, MutableMapping, Protocol, Pattern, Iterable, Optional, Text
|
||||
from typing import Any, Container, Iterable, List, MutableMapping, Optional, Pattern, Protocol, Text
|
||||
|
||||
_Attrs = MutableMapping[Any, Text]
|
||||
|
||||
@@ -12,17 +12,18 @@ TLDS: List[Text]
|
||||
def build_url_re(tlds: Iterable[Text] = ..., protocols: Iterable[Text] = ...) -> Pattern[Text]: ...
|
||||
|
||||
URL_RE: Pattern[Text]
|
||||
PHOTO_RE: Pattern[Text]
|
||||
PROTO_RE: Pattern[Text]
|
||||
EMAIL_RE: Pattern[Text]
|
||||
|
||||
class Linker(object):
|
||||
def __init__(
|
||||
self,
|
||||
callbacks: List[_Callback] = ...,
|
||||
skip_tags: Optional[List[Text]] = ...,
|
||||
callbacks: Iterable[_Callback] = ...,
|
||||
skip_tags: Optional[Container[Text]] = ...,
|
||||
parse_email: bool = ...,
|
||||
url_re: Pattern[Text] = ...,
|
||||
email_re: Pattern[Text] = ...,
|
||||
recognized_tags: Optional[Container[Text]] = ...,
|
||||
) -> None: ...
|
||||
def linkify(self, text: Text) -> Text: ...
|
||||
|
||||
|
||||
13
third_party/2and3/bleach/sanitizer.pyi
vendored
13
third_party/2and3/bleach/sanitizer.pyi
vendored
@@ -1,4 +1,4 @@
|
||||
from typing import List, Dict, Any, Optional, Type, Pattern, Union, Callable, Container, Text
|
||||
from typing import Any, Callable, Container, Dict, Iterable, List, Optional, Pattern, Text, Type, Union
|
||||
|
||||
ALLOWED_TAGS: List[Text]
|
||||
ALLOWED_ATTRIBUTES: Dict[Text, List[Text]]
|
||||
@@ -15,21 +15,20 @@ _Filter = Any
|
||||
class Cleaner(object):
|
||||
def __init__(
|
||||
self,
|
||||
tags: List[Text] = ...,
|
||||
tags: Container[Text] = ...,
|
||||
attributes: Any = ...,
|
||||
styles: List[Text] = ...,
|
||||
protocols: List[Text] = ...,
|
||||
styles: Container[Text] = ...,
|
||||
protocols: Container[Text] = ...,
|
||||
strip: bool = ...,
|
||||
strip_comments: bool = ...,
|
||||
filters: Optional[List[Type[_Filter]]] = ...,
|
||||
filters: Optional[Iterable[_Filter]] = ...,
|
||||
) -> None: ...
|
||||
def clean(self, text: Text) -> Text: ...
|
||||
|
||||
_AttributeFilter = Callable[[Text, Text, Text], bool]
|
||||
_AttributeDict = Dict[Text, Union[Container[Text], _AttributeFilter]]
|
||||
|
||||
def attribute_filter_factory(attributes: Union[_AttributeFilter, _AttributeDict, List[Text]]) -> _AttributeFilter: ...
|
||||
def attribute_filter_factory(attributes: Union[_AttributeFilter, _AttributeDict, Container[Text]]) -> _AttributeFilter: ...
|
||||
|
||||
class BleachSanitizerFilter(object): # TODO: derives from html5lib.sanitizer.Filter
|
||||
|
||||
def __getattr__(self, item: str) -> Any: ... # incomplete
|
||||
|
||||
Reference in New Issue
Block a user