Add html5lib third-party stubs (#5701)

This commit is contained in:
Sebastian Rittau
2021-06-30 06:15:59 +02:00
committed by GitHub
parent bb981bd726
commit f260ea2383
37 changed files with 747 additions and 0 deletions

View File

@@ -30,6 +30,7 @@
"stubs/cryptography",
"stubs/docutils",
"stubs/Flask",
"stubs/html5lib",
"stubs/Jinja2",
"stubs/Markdown",
"stubs/Pillow",

View File

@@ -0,0 +1,2 @@
genshi
lxml

View File

@@ -0,0 +1,2 @@
# Misnamed first argument in implementation
html5lib._inputstream.EncodingBytes.__new__

View File

@@ -0,0 +1 @@
version = "1.1"

View File

@@ -0,0 +1,6 @@
from .html5parser import HTMLParser as HTMLParser, parse as parse, parseFragment as parseFragment
from .serializer import serialize as serialize
from .treebuilders import getTreeBuilder as getTreeBuilder
from .treewalkers import getTreeWalker as getTreeWalker
__version__: str

View File

@@ -0,0 +1,55 @@
from typing import Any
baseChar: str
ideographic: str
combiningCharacter: str
digit: str
extender: str
letter: Any
name: Any
nameFirst: Any
reChar: Any
reCharRange: Any
def charStringToList(chars): ...
def normaliseCharList(charList): ...
max_unicode: Any
def missingRanges(charList): ...
def listToRegexpStr(charList): ...
def hexToInt(hex_str): ...
def escapeRegexp(string): ...
nonXmlNameBMPRegexp: Any
nonXmlNameFirstBMPRegexp: Any
nonPubidCharRegexp: Any
class InfosetFilter:
replacementRegexp: Any
dropXmlnsLocalName: Any
dropXmlnsAttrNs: Any
preventDoubleDashComments: Any
preventDashAtCommentEnd: Any
replaceFormFeedCharacters: Any
preventSingleQuotePubid: Any
replaceCache: Any
def __init__(
self,
dropXmlnsLocalName: bool = ...,
dropXmlnsAttrNs: bool = ...,
preventDoubleDashComments: bool = ...,
preventDashAtCommentEnd: bool = ...,
replaceFormFeedCharacters: bool = ...,
preventSingleQuotePubid: bool = ...,
) -> None: ...
def coerceAttribute(self, name, namespace: Any | None = ...): ...
def coerceElement(self, name): ...
def coerceComment(self, data): ...
def coerceCharacters(self, data): ...
def coercePubid(self, data): ...
def toXmlName(self, name): ...
def getReplacementCharacter(self, char): ...
def fromXmlName(self, name): ...
def escapeChar(self, char): ...
def unescapeChar(self, charcode): ...

View File

@@ -0,0 +1,109 @@
from typing import Any
spaceCharactersBytes: Any
asciiLettersBytes: Any
asciiUppercaseBytes: Any
spacesAngleBrackets: Any
invalid_unicode_no_surrogate: str
invalid_unicode_re: Any
non_bmp_invalid_codepoints: Any
ascii_punctuation_re: Any
charsUntilRegEx: Any
class BufferedStream:
stream: Any
buffer: Any
position: Any
def __init__(self, stream) -> None: ...
def tell(self): ...
def seek(self, pos) -> None: ...
def read(self, bytes): ...
def HTMLInputStream(source, **kwargs): ...
class HTMLUnicodeInputStream:
reportCharacterErrors: Any
newLines: Any
charEncoding: Any
dataStream: Any
def __init__(self, source) -> None: ...
chunk: str
chunkSize: int
chunkOffset: int
errors: Any
prevNumLines: int
prevNumCols: int
def reset(self) -> None: ...
def openStream(self, source): ...
def position(self): ...
def char(self): ...
def readChunk(self, chunkSize: Any | None = ...): ...
def characterErrorsUCS4(self, data) -> None: ...
def characterErrorsUCS2(self, data) -> None: ...
def charsUntil(self, characters, opposite: bool = ...): ...
def unget(self, char) -> None: ...
class HTMLBinaryInputStream(HTMLUnicodeInputStream):
rawStream: Any
numBytesMeta: int
numBytesChardet: int
override_encoding: Any
transport_encoding: Any
same_origin_parent_encoding: Any
likely_encoding: Any
default_encoding: Any
charEncoding: Any
def __init__(
self,
source,
override_encoding: Any | None = ...,
transport_encoding: Any | None = ...,
same_origin_parent_encoding: Any | None = ...,
likely_encoding: Any | None = ...,
default_encoding: str = ...,
useChardet: bool = ...,
) -> None: ...
dataStream: Any
def reset(self) -> None: ...
def openStream(self, source): ...
def determineEncoding(self, chardet: bool = ...): ...
def changeEncoding(self, newEncoding) -> None: ...
def detectBOM(self): ...
def detectEncodingMeta(self): ...
class EncodingBytes(bytes):
def __new__(cls, value): ...
def __init__(self, value) -> None: ...
def __iter__(self): ...
def __next__(self): ...
def next(self): ...
def previous(self): ...
def setPosition(self, position) -> None: ...
def getPosition(self): ...
position: Any
def getCurrentByte(self): ...
currentByte: Any
def skip(self, chars=...): ...
def skipUntil(self, chars): ...
def matchBytes(self, bytes): ...
def jumpTo(self, bytes): ...
class EncodingParser:
data: Any
encoding: Any
def __init__(self, data) -> None: ...
def getEncoding(self): ...
def handleComment(self): ...
def handleMeta(self): ...
def handlePossibleStartTag(self): ...
def handlePossibleEndTag(self): ...
def handlePossibleTag(self, endTag): ...
def handleOther(self): ...
def getAttribute(self): ...
class ContentAttrParser:
data: Any
def __init__(self, data) -> None: ...
def parse(self): ...
def lookupEncoding(encoding): ...

View File

@@ -0,0 +1,93 @@
import sys
from collections import OrderedDict
from typing import Any, Dict
entitiesTrie: Any
if sys.version_info >= (3, 7):
attributeMap = Dict[Any, Any]
else:
attributeMap = OrderedDict[Any, Any]
class HTMLTokenizer:
stream: Any
parser: Any
escapeFlag: bool
lastFourChars: Any
state: Any
escape: bool
currentToken: Any
def __init__(self, stream, parser: Any | None = ..., **kwargs) -> None: ...
tokenQueue: Any
def __iter__(self): ...
def consumeNumberEntity(self, isHex): ...
def consumeEntity(self, allowedChar: Any | None = ..., fromAttribute: bool = ...) -> None: ...
def processEntityInAttribute(self, allowedChar) -> None: ...
def emitCurrentToken(self) -> None: ...
def dataState(self): ...
def entityDataState(self): ...
def rcdataState(self): ...
def characterReferenceInRcdata(self): ...
def rawtextState(self): ...
def scriptDataState(self): ...
def plaintextState(self): ...
def tagOpenState(self): ...
def closeTagOpenState(self): ...
def tagNameState(self): ...
temporaryBuffer: str
def rcdataLessThanSignState(self): ...
def rcdataEndTagOpenState(self): ...
def rcdataEndTagNameState(self): ...
def rawtextLessThanSignState(self): ...
def rawtextEndTagOpenState(self): ...
def rawtextEndTagNameState(self): ...
def scriptDataLessThanSignState(self): ...
def scriptDataEndTagOpenState(self): ...
def scriptDataEndTagNameState(self): ...
def scriptDataEscapeStartState(self): ...
def scriptDataEscapeStartDashState(self): ...
def scriptDataEscapedState(self): ...
def scriptDataEscapedDashState(self): ...
def scriptDataEscapedDashDashState(self): ...
def scriptDataEscapedLessThanSignState(self): ...
def scriptDataEscapedEndTagOpenState(self): ...
def scriptDataEscapedEndTagNameState(self): ...
def scriptDataDoubleEscapeStartState(self): ...
def scriptDataDoubleEscapedState(self): ...
def scriptDataDoubleEscapedDashState(self): ...
def scriptDataDoubleEscapedDashDashState(self): ...
def scriptDataDoubleEscapedLessThanSignState(self): ...
def scriptDataDoubleEscapeEndState(self): ...
def beforeAttributeNameState(self): ...
def attributeNameState(self): ...
def afterAttributeNameState(self): ...
def beforeAttributeValueState(self): ...
def attributeValueDoubleQuotedState(self): ...
def attributeValueSingleQuotedState(self): ...
def attributeValueUnQuotedState(self): ...
def afterAttributeValueState(self): ...
def selfClosingStartTagState(self): ...
def bogusCommentState(self): ...
def markupDeclarationOpenState(self): ...
def commentStartState(self): ...
def commentStartDashState(self): ...
def commentState(self): ...
def commentEndDashState(self): ...
def commentEndState(self): ...
def commentEndBangState(self): ...
def doctypeState(self): ...
def beforeDoctypeNameState(self): ...
def doctypeNameState(self): ...
def afterDoctypeNameState(self): ...
def afterDoctypePublicKeywordState(self): ...
def beforeDoctypePublicIdentifierState(self): ...
def doctypePublicIdentifierDoubleQuotedState(self): ...
def doctypePublicIdentifierSingleQuotedState(self): ...
def afterDoctypePublicIdentifierState(self): ...
def betweenDoctypePublicAndSystemIdentifiersState(self): ...
def afterDoctypeSystemKeywordState(self): ...
def beforeDoctypeSystemIdentifierState(self): ...
def doctypeSystemIdentifierDoubleQuotedState(self): ...
def doctypeSystemIdentifierSingleQuotedState(self): ...
def afterDoctypeSystemIdentifierState(self): ...
def bogusDoctypeState(self): ...
def cdataSectionState(self): ...

View File

@@ -0,0 +1 @@
from .py import Trie as Trie

View File

@@ -0,0 +1,9 @@
from abc import ABCMeta
from collections.abc import Mapping
from typing import Any
class Trie(Mapping[Any, Any], metaclass=ABCMeta):
def keys(self, prefix: Any | None = ...): ...
def has_keys_with_prefix(self, prefix): ...
def longest_prefix(self, prefix): ...
def longest_prefix_item(self, prefix): ...

View File

@@ -0,0 +1,12 @@
from typing import Any
from ._base import Trie as ABCTrie
class Trie(ABCTrie):
def __init__(self, data) -> None: ...
def __contains__(self, key): ...
def __len__(self): ...
def __iter__(self): ...
def __getitem__(self, key): ...
def keys(self, prefix: Any | None = ...): ...
def has_keys_with_prefix(self, prefix): ...

View File

@@ -0,0 +1,24 @@
from collections.abc import Mapping
from typing import Any, Dict
supports_lone_surrogates: bool
class MethodDispatcher(Dict[Any, Any]):
default: Any
def __init__(self, items=...) -> None: ...
def __getitem__(self, key): ...
def __get__(self, instance, owner: Any | None = ...): ...
class BoundMethodDispatcher(Mapping[Any, Any]):
instance: Any
dispatcher: Any
def __init__(self, instance, dispatcher) -> None: ...
def __getitem__(self, key): ...
def get(self, key, default): ...
def __iter__(self): ...
def __len__(self): ...
def __contains__(self, key): ...
def isSurrogatePair(data): ...
def surrogatePairToCodepoint(data): ...
def moduleFactoryFactory(factory): ...

View File

@@ -0,0 +1,37 @@
from typing import Any
EOF: Any
E: Any
namespaces: Any
scopingElements: Any
formattingElements: Any
specialElements: Any
htmlIntegrationPointElements: Any
mathmlTextIntegrationPointElements: Any
adjustSVGAttributes: Any
adjustMathMLAttributes: Any
adjustForeignAttributes: Any
unadjustForeignAttributes: Any
spaceCharacters: Any
tableInsertModeElements: Any
asciiLowercase: Any
asciiUppercase: Any
asciiLetters: Any
digits: Any
hexDigits: Any
asciiUpper2Lower: Any
headingElements: Any
voidElements: Any
cdataElements: Any
rcdataElements: Any
booleanAttributes: Any
entitiesWindows1252: Any
xmlEntities: Any
entities: Any
replacementCharacters: Any
tokenTypes: Any
tagTokenTypes: Any
prefixes: Any
class DataLossWarning(UserWarning): ...
class _ReparseException(Exception): ...

View File

@@ -0,0 +1,4 @@
from . import base
class Filter(base.Filter):
def __iter__(self): ...

View File

@@ -0,0 +1,7 @@
from typing import Any
class Filter:
source: Any
def __init__(self, source) -> None: ...
def __iter__(self): ...
def __getattr__(self, name): ...

View File

@@ -0,0 +1,8 @@
from typing import Any
from . import base
class Filter(base.Filter):
encoding: Any
def __init__(self, source, encoding) -> None: ...
def __iter__(self): ...

View File

@@ -0,0 +1,8 @@
from typing import Any
from . import base
class Filter(base.Filter):
require_matching_tags: Any
def __init__(self, source, require_matching_tags: bool = ...) -> None: ...
def __iter__(self): ...

View File

@@ -0,0 +1,7 @@
from . import base
class Filter(base.Filter):
def slider(self) -> None: ...
def __iter__(self): ...
def is_optional_start(self, tagname, previous, next): ...
def is_optional_end(self, tagname, next): ...

View File

@@ -0,0 +1,34 @@
from typing import Any
from . import base
class Filter(base.Filter):
allowed_elements: Any
allowed_attributes: Any
allowed_css_properties: Any
allowed_css_keywords: Any
allowed_svg_properties: Any
allowed_protocols: Any
allowed_content_types: Any
attr_val_is_uri: Any
svg_attr_val_allows_ref: Any
svg_allow_local_href: Any
def __init__(
self,
source,
allowed_elements=...,
allowed_attributes=...,
allowed_css_properties=...,
allowed_css_keywords=...,
allowed_svg_properties=...,
allowed_protocols=...,
allowed_content_types=...,
attr_val_is_uri=...,
svg_attr_val_allows_ref=...,
svg_allow_local_href=...,
) -> None: ...
def __iter__(self): ...
def sanitize_token(self, token): ...
def allowed_token(self, token): ...
def disallowed_token(self, token): ...
def sanitize_css(self, style): ...

View File

@@ -0,0 +1,11 @@
from typing import Any
from . import base
SPACES_REGEX: Any
class Filter(base.Filter):
spacePreserveElements: Any
def __iter__(self): ...
def collapse_spaces(text): ...

View File

@@ -0,0 +1,50 @@
from _typeshed import SupportsRead
from typing import Any
def parse(
doc: str | bytes | SupportsRead[str] | SupportsRead[bytes],
treebuilder: str = ...,
namespaceHTMLElements: bool = ...,
**kwargs,
): ...
def parseFragment(doc, container: str = ..., treebuilder: str = ..., namespaceHTMLElements: bool = ..., **kwargs): ...
def method_decorator_metaclass(function): ...
class HTMLParser:
strict: Any
tree: Any
errors: Any
phases: Any
def __init__(
self, tree: Any | None = ..., strict: bool = ..., namespaceHTMLElements: bool = ..., debug: bool = ...
) -> None: ...
firstStartTag: bool
log: Any
compatMode: str
innerHTML: Any
phase: Any
lastPhase: Any
beforeRCDataPhase: Any
framesetOK: bool
def reset(self) -> None: ...
@property
def documentEncoding(self): ...
def isHTMLIntegrationPoint(self, element): ...
def isMathMLTextIntegrationPoint(self, element): ...
def mainLoop(self) -> None: ...
def parse(self, stream, *args, **kwargs): ...
def parseFragment(self, stream, *args, **kwargs): ...
def parseError(self, errorcode: str = ..., datavars: Any | None = ...) -> None: ...
def adjustMathMLAttributes(self, token) -> None: ...
def adjustSVGAttributes(self, token) -> None: ...
def adjustForeignAttributes(self, token) -> None: ...
def reparseTokenNormal(self, token) -> None: ...
def resetInsertionMode(self) -> None: ...
originalPhase: Any
def parseRCDataRawtext(self, token, contentType) -> None: ...
def getPhases(debug): ...
def adjust_attributes(token, replacements) -> None: ...
def impliedTagToken(name, type: str = ..., attributes: Any | None = ..., selfClosing: bool = ...): ...
class ParseError(Exception): ...

View File

@@ -0,0 +1,37 @@
from typing import Any, overload
def htmlentityreplace_errors(exc: Exception) -> tuple[str | bytes, int]: ...
@overload
def serialize(input, tree: str = ..., encoding: None = ..., **serializer_opts) -> str: ...
@overload
def serialize(input, tree: str, encoding: str, **serializer_opts) -> bytes: ...
@overload
def serialize(input, *, encoding: str, **serializer_opts) -> bytes: ...
class HTMLSerializer:
quote_attr_values: str
quote_char: str
use_best_quote_char: bool
omit_optional_tags: bool
minimize_boolean_attributes: bool
use_trailing_solidus: bool
space_before_trailing_solidus: bool
escape_lt_in_attrs: bool
escape_rcdata: bool
resolve_entities: bool
alphabetical_attributes: bool
inject_meta_charset: bool
strip_whitespace: bool
sanitize: bool
options: Any
errors: Any
strict: bool
def __init__(self, **kwargs) -> None: ...
def encode(self, string): ...
def encodeStrict(self, string): ...
encoding: Any
def serialize(self, treewalker, encoding: Any | None = ...) -> None: ...
def render(self, treewalker, encoding: Any | None = ...): ...
def serializeError(self, data: str = ...) -> None: ...
class SerializeError(Exception): ...

View File

@@ -0,0 +1 @@
from . import genshi as genshi, sax as sax

View File

@@ -0,0 +1 @@
def to_genshi(walker) -> None: ...

View File

@@ -0,0 +1,5 @@
from typing import Any
prefix_mapping: Any
def to_sax(walker, handler) -> None: ...

View File

@@ -0,0 +1,5 @@
from typing import Any
treeBuilderCache: Any
def getTreeBuilder(treeType, implementation: Any | None = ..., **kwargs): ...

View File

@@ -0,0 +1,55 @@
from typing import Any, List
Marker: Any
listElementsMap: Any
class Node:
name: Any
parent: Any
value: Any
attributes: Any
childNodes: Any
def __init__(self, name) -> None: ...
def appendChild(self, node) -> None: ...
def insertText(self, data, insertBefore: Any | None = ...) -> None: ...
def insertBefore(self, node, refNode) -> None: ...
def removeChild(self, node) -> None: ...
def reparentChildren(self, newParent) -> None: ...
def cloneNode(self) -> None: ...
def hasContent(self) -> None: ...
class ActiveFormattingElements(List[Any]):
def append(self, node) -> None: ...
def nodesEqual(self, node1, node2): ...
class TreeBuilder:
documentClass: Any
elementClass: Any
commentClass: Any
doctypeClass: Any
fragmentClass: Any
defaultNamespace: str
def __init__(self, namespaceHTMLElements) -> None: ...
openElements: Any
activeFormattingElements: Any
headPointer: Any
formPointer: Any
insertFromTable: bool
document: Any
def reset(self) -> None: ...
def elementInScope(self, target, variant: Any | None = ...): ...
def reconstructActiveFormattingElements(self) -> None: ...
def clearActiveFormattingElements(self) -> None: ...
def elementInActiveFormattingElements(self, name): ...
def insertRoot(self, token) -> None: ...
def insertDoctype(self, token) -> None: ...
def insertComment(self, token, parent: Any | None = ...) -> None: ...
def createElement(self, token): ...
def insertElementNormal(self, token): ...
def insertElementTable(self, token): ...
def insertText(self, data, parent: Any | None = ...) -> None: ...
def getTableMisnestedNodePosition(self): ...
def generateImpliedEndTags(self, exclude: Any | None = ...) -> None: ...
def getDocument(self): ...
def getFragment(self): ...
def testSerializer(self, node) -> None: ...

View File

@@ -0,0 +1,5 @@
from typing import Any
def getDomBuilder(DomImplementation): ...
getDomModule: Any

View File

@@ -0,0 +1,7 @@
from typing import Any
tag_regexp: Any
def getETreeBuilder(ElementTreeImplementation, fullTree: bool = ...): ...
getETreeModule: Any

View File

@@ -0,0 +1,43 @@
from typing import Any
from . import base
fullTree: bool
tag_regexp: Any
comment_type: Any
class DocumentType:
name: Any
publicId: Any
systemId: Any
def __init__(self, name, publicId, systemId) -> None: ...
class Document:
def __init__(self) -> None: ...
def appendChild(self, element) -> None: ...
childNodes: Any
def testSerializer(element): ...
def tostring(element): ...
class TreeBuilder(base.TreeBuilder):
documentClass: Any
doctypeClass: Any
elementClass: Any
commentClass: Any
fragmentClass: Any
implementation: Any
namespaceHTMLElements: Any
def __init__(self, namespaceHTMLElements, fullTree: bool = ...): ...
insertComment: Any
initial_comments: Any
doctype: Any
def reset(self) -> None: ...
def testSerializer(self, element): ...
def getDocument(self): ...
def getFragment(self): ...
def insertDoctype(self, token) -> None: ...
def insertCommentInitial(self, data, parent: Any | None = ...) -> None: ...
def insertCommentMain(self, data, parent: Any | None = ...) -> None: ...
document: Any
def insertRoot(self, token) -> None: ...

View File

@@ -0,0 +1,4 @@
from typing import Any
def getTreeWalker(treeType, implementation: Any | None = ..., **kwargs): ...
def pprint(walker): ...

View File

@@ -0,0 +1,30 @@
from typing import Any
DOCUMENT: Any
DOCTYPE: Any
TEXT: Any
ELEMENT: Any
COMMENT: Any
ENTITY: Any
UNKNOWN: str
class TreeWalker:
tree: Any
def __init__(self, tree) -> None: ...
def __iter__(self): ...
def error(self, msg): ...
def emptyTag(self, namespace, name, attrs, hasChildren: bool = ...) -> None: ...
def startTag(self, namespace, name, attrs): ...
def endTag(self, namespace, name): ...
def text(self, data) -> None: ...
def comment(self, data): ...
def doctype(self, name, publicId: Any | None = ..., systemId: Any | None = ...): ...
def entity(self, name): ...
def unknown(self, nodeType): ...
class NonRecursiveTreeWalker(TreeWalker):
def getNodeDetails(self, node) -> None: ...
def getFirstChild(self, node) -> None: ...
def getNextSibling(self, node) -> None: ...
def getParentNode(self, node) -> None: ...
def __iter__(self): ...

View File

@@ -0,0 +1,7 @@
from .base import NonRecursiveTreeWalker
class TreeWalker(NonRecursiveTreeWalker):
def getNodeDetails(self, node): ...
def getFirstChild(self, node): ...
def getNextSibling(self, node): ...
def getParentNode(self, node): ...

View File

@@ -0,0 +1,7 @@
from typing import Any
tag_regexp: Any
def getETreeBuilder(ElementTreeImplementation): ...
getETreeModule: Any

View File

@@ -0,0 +1,54 @@
from typing import Any
from .base import NonRecursiveTreeWalker
def ensure_str(s): ...
class Root:
elementtree: Any
children: Any
text: Any
tail: Any
def __init__(self, et) -> None: ...
def __getitem__(self, key): ...
def getnext(self) -> None: ...
def __len__(self): ...
class Doctype:
root_node: Any
name: Any
public_id: Any
system_id: Any
text: Any
tail: Any
def __init__(self, root_node, name, public_id, system_id) -> None: ...
def getnext(self): ...
class FragmentRoot(Root):
children: Any
text: Any
def __init__(self, children) -> None: ...
def getnext(self) -> None: ...
class FragmentWrapper:
root_node: Any
obj: Any
text: Any
tail: Any
def __init__(self, fragment_root, obj) -> None: ...
def __getattr__(self, name): ...
def getnext(self): ...
def __getitem__(self, key): ...
def __bool__(self): ...
def getparent(self) -> None: ...
def __unicode__(self): ...
def __len__(self): ...
class TreeWalker(NonRecursiveTreeWalker):
fragmentChildren: Any
filter: Any
def __init__(self, tree) -> None: ...
def getNodeDetails(self, node): ...
def getFirstChild(self, node): ...
def getNextSibling(self, node): ...
def getParentNode(self, node): ...

View File

@@ -0,0 +1,5 @@
from . import base
class TreeWalker(base.TreeWalker):
def __iter__(self): ...
def tokens(self, event, next) -> None: ...