diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index d50ee1dd9..5974705a5 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -30,6 +30,7 @@ "stubs/cryptography", "stubs/docutils", "stubs/Flask", + "stubs/html5lib", "stubs/Jinja2", "stubs/Markdown", "stubs/Pillow", diff --git a/stubs/html5lib/@tests/requirements-stubtest.txt b/stubs/html5lib/@tests/requirements-stubtest.txt new file mode 100644 index 000000000..0bf46c1cc --- /dev/null +++ b/stubs/html5lib/@tests/requirements-stubtest.txt @@ -0,0 +1,2 @@ +genshi +lxml diff --git a/stubs/html5lib/@tests/stubtest_allowlist.txt b/stubs/html5lib/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..fe341582b --- /dev/null +++ b/stubs/html5lib/@tests/stubtest_allowlist.txt @@ -0,0 +1,2 @@ +# Misnamed first argument in implementation +html5lib._inputstream.EncodingBytes.__new__ diff --git a/stubs/html5lib/METADATA.toml b/stubs/html5lib/METADATA.toml new file mode 100644 index 000000000..bad265e4f --- /dev/null +++ b/stubs/html5lib/METADATA.toml @@ -0,0 +1 @@ +version = "1.1" diff --git a/stubs/html5lib/html5lib/__init__.pyi b/stubs/html5lib/html5lib/__init__.pyi new file mode 100644 index 000000000..709bc6613 --- /dev/null +++ b/stubs/html5lib/html5lib/__init__.pyi @@ -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 diff --git a/stubs/html5lib/html5lib/_ihatexml.pyi b/stubs/html5lib/html5lib/_ihatexml.pyi new file mode 100644 index 000000000..dff7e852e --- /dev/null +++ b/stubs/html5lib/html5lib/_ihatexml.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi new file mode 100644 index 000000000..ad08d3587 --- /dev/null +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/_tokenizer.pyi b/stubs/html5lib/html5lib/_tokenizer.pyi new file mode 100644 index 000000000..cf62e2ca6 --- /dev/null +++ b/stubs/html5lib/html5lib/_tokenizer.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/_trie/__init__.pyi b/stubs/html5lib/html5lib/_trie/__init__.pyi new file mode 100644 index 000000000..7095d84cb --- /dev/null +++ b/stubs/html5lib/html5lib/_trie/__init__.pyi @@ -0,0 +1 @@ +from .py import Trie as Trie diff --git a/stubs/html5lib/html5lib/_trie/_base.pyi b/stubs/html5lib/html5lib/_trie/_base.pyi new file mode 100644 index 000000000..138c91ccd --- /dev/null +++ b/stubs/html5lib/html5lib/_trie/_base.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/_trie/py.pyi b/stubs/html5lib/html5lib/_trie/py.pyi new file mode 100644 index 000000000..cd3e66dd4 --- /dev/null +++ b/stubs/html5lib/html5lib/_trie/py.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/_utils.pyi b/stubs/html5lib/html5lib/_utils.pyi new file mode 100644 index 000000000..c6f85f5a6 --- /dev/null +++ b/stubs/html5lib/html5lib/_utils.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/constants.pyi b/stubs/html5lib/html5lib/constants.pyi new file mode 100644 index 000000000..b8a3ac8f1 --- /dev/null +++ b/stubs/html5lib/html5lib/constants.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/filters/__init__.pyi b/stubs/html5lib/html5lib/filters/__init__.pyi new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/html5lib/html5lib/filters/alphabeticalattributes.pyi b/stubs/html5lib/html5lib/filters/alphabeticalattributes.pyi new file mode 100644 index 000000000..20b694d65 --- /dev/null +++ b/stubs/html5lib/html5lib/filters/alphabeticalattributes.pyi @@ -0,0 +1,4 @@ +from . import base + +class Filter(base.Filter): + def __iter__(self): ... diff --git a/stubs/html5lib/html5lib/filters/base.pyi b/stubs/html5lib/html5lib/filters/base.pyi new file mode 100644 index 000000000..16d3726e0 --- /dev/null +++ b/stubs/html5lib/html5lib/filters/base.pyi @@ -0,0 +1,7 @@ +from typing import Any + +class Filter: + source: Any + def __init__(self, source) -> None: ... + def __iter__(self): ... + def __getattr__(self, name): ... diff --git a/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi b/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi new file mode 100644 index 000000000..9cde8fde3 --- /dev/null +++ b/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/filters/lint.pyi b/stubs/html5lib/html5lib/filters/lint.pyi new file mode 100644 index 000000000..5803963a1 --- /dev/null +++ b/stubs/html5lib/html5lib/filters/lint.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/filters/optionaltags.pyi b/stubs/html5lib/html5lib/filters/optionaltags.pyi new file mode 100644 index 000000000..5d53a467e --- /dev/null +++ b/stubs/html5lib/html5lib/filters/optionaltags.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/filters/sanitizer.pyi b/stubs/html5lib/html5lib/filters/sanitizer.pyi new file mode 100644 index 000000000..176e81a01 --- /dev/null +++ b/stubs/html5lib/html5lib/filters/sanitizer.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/filters/whitespace.pyi b/stubs/html5lib/html5lib/filters/whitespace.pyi new file mode 100644 index 000000000..117aaf641 --- /dev/null +++ b/stubs/html5lib/html5lib/filters/whitespace.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/html5parser.pyi b/stubs/html5lib/html5lib/html5parser.pyi new file mode 100644 index 000000000..8b5215b0f --- /dev/null +++ b/stubs/html5lib/html5lib/html5parser.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/serializer.pyi b/stubs/html5lib/html5lib/serializer.pyi new file mode 100644 index 000000000..210c725cc --- /dev/null +++ b/stubs/html5lib/html5lib/serializer.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/treeadapters/__init__.pyi b/stubs/html5lib/html5lib/treeadapters/__init__.pyi new file mode 100644 index 000000000..bf1267485 --- /dev/null +++ b/stubs/html5lib/html5lib/treeadapters/__init__.pyi @@ -0,0 +1 @@ +from . import genshi as genshi, sax as sax diff --git a/stubs/html5lib/html5lib/treeadapters/genshi.pyi b/stubs/html5lib/html5lib/treeadapters/genshi.pyi new file mode 100644 index 000000000..fa42d5d09 --- /dev/null +++ b/stubs/html5lib/html5lib/treeadapters/genshi.pyi @@ -0,0 +1 @@ +def to_genshi(walker) -> None: ... diff --git a/stubs/html5lib/html5lib/treeadapters/sax.pyi b/stubs/html5lib/html5lib/treeadapters/sax.pyi new file mode 100644 index 000000000..87ebcb1cb --- /dev/null +++ b/stubs/html5lib/html5lib/treeadapters/sax.pyi @@ -0,0 +1,5 @@ +from typing import Any + +prefix_mapping: Any + +def to_sax(walker, handler) -> None: ... diff --git a/stubs/html5lib/html5lib/treebuilders/__init__.pyi b/stubs/html5lib/html5lib/treebuilders/__init__.pyi new file mode 100644 index 000000000..a9cd20041 --- /dev/null +++ b/stubs/html5lib/html5lib/treebuilders/__init__.pyi @@ -0,0 +1,5 @@ +from typing import Any + +treeBuilderCache: Any + +def getTreeBuilder(treeType, implementation: Any | None = ..., **kwargs): ... diff --git a/stubs/html5lib/html5lib/treebuilders/base.pyi b/stubs/html5lib/html5lib/treebuilders/base.pyi new file mode 100644 index 000000000..12e89bb29 --- /dev/null +++ b/stubs/html5lib/html5lib/treebuilders/base.pyi @@ -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: ... diff --git a/stubs/html5lib/html5lib/treebuilders/dom.pyi b/stubs/html5lib/html5lib/treebuilders/dom.pyi new file mode 100644 index 000000000..12de3344d --- /dev/null +++ b/stubs/html5lib/html5lib/treebuilders/dom.pyi @@ -0,0 +1,5 @@ +from typing import Any + +def getDomBuilder(DomImplementation): ... + +getDomModule: Any diff --git a/stubs/html5lib/html5lib/treebuilders/etree.pyi b/stubs/html5lib/html5lib/treebuilders/etree.pyi new file mode 100644 index 000000000..f4b8e54b5 --- /dev/null +++ b/stubs/html5lib/html5lib/treebuilders/etree.pyi @@ -0,0 +1,7 @@ +from typing import Any + +tag_regexp: Any + +def getETreeBuilder(ElementTreeImplementation, fullTree: bool = ...): ... + +getETreeModule: Any diff --git a/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi b/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi new file mode 100644 index 000000000..1016b9091 --- /dev/null +++ b/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi @@ -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: ... diff --git a/stubs/html5lib/html5lib/treewalkers/__init__.pyi b/stubs/html5lib/html5lib/treewalkers/__init__.pyi new file mode 100644 index 000000000..eb1e26e94 --- /dev/null +++ b/stubs/html5lib/html5lib/treewalkers/__init__.pyi @@ -0,0 +1,4 @@ +from typing import Any + +def getTreeWalker(treeType, implementation: Any | None = ..., **kwargs): ... +def pprint(walker): ... diff --git a/stubs/html5lib/html5lib/treewalkers/base.pyi b/stubs/html5lib/html5lib/treewalkers/base.pyi new file mode 100644 index 000000000..34eee4b3e --- /dev/null +++ b/stubs/html5lib/html5lib/treewalkers/base.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/treewalkers/dom.pyi b/stubs/html5lib/html5lib/treewalkers/dom.pyi new file mode 100644 index 000000000..72a71d00a --- /dev/null +++ b/stubs/html5lib/html5lib/treewalkers/dom.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/treewalkers/etree.pyi b/stubs/html5lib/html5lib/treewalkers/etree.pyi new file mode 100644 index 000000000..33f6d8002 --- /dev/null +++ b/stubs/html5lib/html5lib/treewalkers/etree.pyi @@ -0,0 +1,7 @@ +from typing import Any + +tag_regexp: Any + +def getETreeBuilder(ElementTreeImplementation): ... + +getETreeModule: Any diff --git a/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi b/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi new file mode 100644 index 000000000..c9fb06cee --- /dev/null +++ b/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi @@ -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): ... diff --git a/stubs/html5lib/html5lib/treewalkers/genshi.pyi b/stubs/html5lib/html5lib/treewalkers/genshi.pyi new file mode 100644 index 000000000..2e75daf20 --- /dev/null +++ b/stubs/html5lib/html5lib/treewalkers/genshi.pyi @@ -0,0 +1,5 @@ +from . import base + +class TreeWalker(base.TreeWalker): + def __iter__(self): ... + def tokens(self, event, next) -> None: ...