mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Update bleach stubs to version 5 (#7612)
This commit is contained in:
@@ -1 +1,2 @@
|
||||
bleach.css_sanitizer # Requires tinycss2 to be installed
|
||||
bleach.html5lib_shim.*
|
||||
|
||||
@@ -1 +1 @@
|
||||
version = "4.1.*"
|
||||
version = "5.0.*"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from collections.abc import Container, Iterable
|
||||
from typing import Any
|
||||
|
||||
from bleach.linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker, _Callback
|
||||
from bleach.sanitizer import (
|
||||
from .css_sanitizer import CSSSanitizer
|
||||
from .linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker, _Callback
|
||||
from .sanitizer import (
|
||||
ALLOWED_ATTRIBUTES as ALLOWED_ATTRIBUTES,
|
||||
ALLOWED_PROTOCOLS as ALLOWED_PROTOCOLS,
|
||||
ALLOWED_STYLES as ALLOWED_STYLES,
|
||||
ALLOWED_TAGS as ALLOWED_TAGS,
|
||||
Cleaner as Cleaner,
|
||||
_Attributes,
|
||||
@@ -15,16 +14,15 @@ __all__ = ["clean", "linkify"]
|
||||
|
||||
__releasedate__: str
|
||||
__version__: str
|
||||
VERSION: Any # packaging.version.Version
|
||||
|
||||
def clean(
|
||||
text: str,
|
||||
tags: Container[str] = ...,
|
||||
attributes: _Attributes = ...,
|
||||
styles: Container[str] = ...,
|
||||
protocols: Container[str] = ...,
|
||||
strip: bool = ...,
|
||||
strip_comments: bool = ...,
|
||||
css_sanitizer: CSSSanitizer | None = ...,
|
||||
) -> str: ...
|
||||
def linkify(
|
||||
text: str, callbacks: Iterable[_Callback] = ..., skip_tags: Container[str] | None = ..., parse_email: bool = ...
|
||||
|
||||
11
stubs/bleach/bleach/css_sanitizer.pyi
Normal file
11
stubs/bleach/bleach/css_sanitizer.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from collections.abc import Container
|
||||
|
||||
ALLOWED_CSS_PROPERTIES: frozenset[str]
|
||||
ALLOWED_SVG_PROPERTIES: frozenset[str]
|
||||
|
||||
class CSSSanitizer:
|
||||
allowed_css_properties: Container[str]
|
||||
allowed_svg_properties: Container[str]
|
||||
|
||||
def __init__(self, allowed_css_properties: Container[str] = ..., allowed_svg_properties: Container[str] = ...) -> None: ...
|
||||
def sanitize_css(self, style: str) -> str: ...
|
||||
@@ -1,11 +1,11 @@
|
||||
from collections.abc import Callable, Container, Iterable
|
||||
from typing import Any, Pattern
|
||||
|
||||
from .css_sanitizer import CSSSanitizer
|
||||
from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter
|
||||
|
||||
ALLOWED_TAGS: list[str]
|
||||
ALLOWED_ATTRIBUTES: dict[str, list[str]]
|
||||
ALLOWED_STYLES: list[str]
|
||||
ALLOWED_PROTOCOLS: list[str]
|
||||
|
||||
INVISIBLE_CHARACTERS: str
|
||||
@@ -18,11 +18,11 @@ _Filter = Any
|
||||
class Cleaner:
|
||||
tags: Container[str]
|
||||
attributes: _Attributes
|
||||
styles: Container[str]
|
||||
protocols: Container[str]
|
||||
strip: bool
|
||||
strip_comments: bool
|
||||
filters: Iterable[_Filter]
|
||||
css_sanitizer: CSSSanitizer | None
|
||||
parser: BleachHTMLParser
|
||||
walker: Any
|
||||
serializer: BleachHTMLSerializer
|
||||
@@ -30,11 +30,11 @@ class Cleaner:
|
||||
self,
|
||||
tags: Container[str] = ...,
|
||||
attributes: _Attributes = ...,
|
||||
styles: Container[str] = ...,
|
||||
protocols: Container[str] = ...,
|
||||
strip: bool = ...,
|
||||
strip_comments: bool = ...,
|
||||
filters: Iterable[_Filter] | None = ...,
|
||||
css_sanitizer: CSSSanitizer | None = ...,
|
||||
) -> None: ...
|
||||
def clean(self, text: str) -> str: ...
|
||||
|
||||
@@ -51,9 +51,12 @@ class BleachSanitizerFilter(SanitizerFilter):
|
||||
def __init__(
|
||||
self,
|
||||
source,
|
||||
allowed_elements: Container[str] = ...,
|
||||
attributes: _Attributes = ...,
|
||||
allowed_protocols: Container[str] = ...,
|
||||
strip_disallowed_elements: bool = ...,
|
||||
strip_html_comments: bool = ...,
|
||||
css_sanitizer: CSSSanitizer | None = ...,
|
||||
**kwargs,
|
||||
) -> None: ...
|
||||
def sanitize_stream(self, token_iterator): ...
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, overload
|
||||
|
||||
@overload
|
||||
def alphabetize_attributes(attrs: None) -> None: ...
|
||||
@overload
|
||||
def alphabetize_attributes(attrs: Mapping[Any, str]) -> OrderedDict[Any, str]: ...
|
||||
Reference in New Issue
Block a user