-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Complete stubs for bleach
#9314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
4375fb5
Mark `bleach` as complete
sobolevn 49d8286
Fix CI
sobolevn b924759
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 146a810
Merge branch 'main' into mark-bleach
AlexWaygood 18e31e5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 24e2ad3
Fix some obvious merge issues
AlexWaygood 1b526fe
fix more mistakes when merging `main`
AlexWaygood 198f6a6
Update linkifier.pyi
AlexWaygood 22fd76e
Remove unused allowlist entries
AlexWaygood dc39112
Merge branch 'main' into mark-bleach
AlexWaygood 3245722
Merge branch 'main' into mark-bleach
AlexWaygood c4767d5
Update stubs/bleach/METADATA.toml
AlexWaygood 704cb27
Update stubs/bleach/bleach/html5lib_shim.pyi
AlexWaygood 5950664
fix mypy
AlexWaygood c723045
Merge branch 'main' into mark-bleach
Avasam c9faed8
Post-merge remove bleach from pyrightconfig.stricter.json
Avasam 7b72eef
Merge branch 'main' into mark-bleach
AlexWaygood 96fc2c4
Merge branch 'main' of https://github.com/python/typeshed into mark-b…
Avasam c79dca1
Ran stubdefaulter
Avasam 7723b65
Complete missing types
Avasam ea95d05
Address PR comments
Avasam a4ee82c
More PR comments
Avasam 5a39614
Mark uppercase names as Final
Avasam 3f865d3
Reduce allowlist entried and indicate possible runtime failure
Avasam 5f48c83
typo
Avasam 9c88154
Update stubs/html5lib/html5lib/_inputstream.pyi
Avasam e318888
Update stubs/bleach/bleach/html5lib_shim.pyi
Avasam c4aeaa5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
bleach.css_sanitizer # Requires tinycss2 to be installed | ||
bleach.html5lib_shim.* | ||
# Internal private stuff: | ||
bleach._vendor.* | ||
|
||
# Is a property returning a method, simplified: | ||
bleach.html5lib_shim.InputStreamWithMemory.changeEncoding | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
version = "6.1.*" | ||
requires = ["types-html5lib"] | ||
upstream_repository = "https://github.com/mozilla/bleach" | ||
partial_stub = true | ||
|
||
[tool.stubtest] | ||
ignore_missing_stub = true | ||
extras = ["css"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,70 @@ | ||
from _typeshed import Incomplete | ||
import re | ||
from codecs import CodecInfo | ||
from collections.abc import Generator, Iterable, Iterator | ||
from typing import Any, Final, Protocol | ||
|
||
class HTMLParser: # actually html5lib.HTMLParser | ||
def __getattr__(self, __name: str) -> Incomplete: ... | ||
# We don't re-export any `html5lib` types / values here, because they are not | ||
# really public and may change at any time. This is just a helper module, | ||
# import things directly from `html5lib` instead! | ||
from html5lib import HTMLParser | ||
from html5lib._inputstream import HTMLBinaryInputStream, HTMLUnicodeInputStream | ||
from html5lib._tokenizer import HTMLTokenizer | ||
from html5lib._trie import Trie | ||
from html5lib.serializer import HTMLSerializer | ||
from html5lib.treewalkers.base import TreeWalker | ||
|
||
class Filter: # actually html5lib.filters.base.Filter | ||
source: Incomplete | ||
def __init__(self, source) -> None: ... | ||
def __iter__(self) -> Iterator[Incomplete]: ... | ||
def __getattr__(self, name: str) -> Incomplete: ... # copy attributes from source | ||
# Is actually webencodings.Encoding | ||
class _Encoding(Protocol): | ||
name: str | ||
codec_info: CodecInfo | ||
def __init__(self, name: str, codec_info: CodecInfo) -> None: ... | ||
|
||
class SanitizerFilter: # actually html5lib.filters.sanitizer.Filter | ||
def __getattr__(self, __name: str) -> Incomplete: ... | ||
HTML_TAGS: Final[frozenset[str]] | ||
HTML_TAGS_BLOCK_LEVEL: Final[frozenset[str]] | ||
AMP_SPLIT_RE: Final[re.Pattern[str]] | ||
ENTITIES: Final[dict[str, str]] | ||
ENTITIES_TRIE: Final[Trie] | ||
TAG_TOKEN_TYPES: Final[set[int]] | ||
TAG_TOKEN_TYPE_CHARACTERS: Final[int] | ||
TAG_TOKEN_TYPE_END: Final[int] | ||
TAG_TOKEN_TYPE_PARSEERROR: Final[int] | ||
TAG_TOKEN_TYPE_START: Final[int] | ||
|
||
class HTMLSerializer: # actually html5lib.serializer.HTMLSerializer | ||
def __getattr__(self, __name: str) -> Incomplete: ... | ||
class InputStreamWithMemory: | ||
position = HTMLUnicodeInputStream.position | ||
reset = HTMLUnicodeInputStream.reset | ||
def __init__(self, inner_stream: HTMLUnicodeInputStream) -> None: ... | ||
@property | ||
def errors(self) -> list[str]: ... | ||
@property | ||
def charEncoding(self) -> tuple[_Encoding, str]: ... | ||
# If inner_stream wasn't a HTMLBinaryInputStream, this will error at runtime | ||
# Is a property returning a method, simplified: | ||
changeEncoding = HTMLBinaryInputStream.changeEncoding | ||
def char(self) -> str: ... | ||
def charsUntil(self, characters: Iterable[str], opposite: bool = False) -> str: ... | ||
def unget(self, char: str | None) -> None: ... | ||
def get_tag(self) -> str: ... | ||
8000 | def start_tag(self) -> None: ... | |
|
||
class BleachHTMLTokenizer(HTMLTokenizer): | ||
consume_entities: bool | ||
stream: InputStreamWithMemory | ||
emitted_last_token: dict[str, Any] | None | ||
def __init__(self, consume_entities: bool = False, **kwargs: Any) -> None: ... | ||
|
||
class BleachHTMLParser(HTMLParser): | ||
tags: list[str] | None | ||
strip: bool | ||
consume_entities: bool | ||
def __init__(self, tags: Iterable[str] | None, strip: bool, consume_entities: bool, **kwargs) -> None: ... | ||
def __init__(self, tags: Iterable[str] | None, strip: bool, consume_entities: bool, **kwargs: Any) -> None: ... | ||
|
||
class BleachHTMLSerializer(HTMLSerializer): | ||
escape_rcdata: bool | ||
def escape_base_amp(self, stoken: str) -> Generator[str, None, None]: ... | ||
def serialize(self, treewalker, encoding: str | None = None) -> Generator[str, None, None]: ... | ||
def serialize(self, treewalker: TreeWalker, encoding: str | None = None) -> Generator[str, None, None]: ... # type: ignore[override] | ||
|
||
def __getattr__(__name: str) -> Incomplete: ... | ||
def convert_entity(value: str) -> str | None: ... | ||
def convert_entities(text: str) -> str: ... | ||
def match_entity(stream: str) -> str | None: ... | ||
def next_possible_entity(text: str) -> Iterator[str]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from urllib import parse as parse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.