diff --git a/stubs/html5lib/METADATA.toml b/stubs/html5lib/METADATA.toml index b1fa786dac26..23a4684130a6 100644 --- a/stubs/html5lib/METADATA.toml +++ b/stubs/html5lib/METADATA.toml @@ -1,7 +1,5 @@ version = "1.1.*" upstream_repository = "https://github.com/html5lib/html5lib-python" -partial_stub = true [tool.stubtest] -ignore_missing_stub = true extras = ["all"] diff --git a/stubs/html5lib/html5lib/__init__.pyi b/stubs/html5lib/html5lib/__init__.pyi index 709bc661394a..3a24c70e9f41 100644 --- a/stubs/html5lib/html5lib/__init__.pyi +++ b/stubs/html5lib/html5lib/__init__.pyi @@ -1,6 +1,10 @@ +from typing import Final + 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 +__all__ = ["HTMLParser", "parse", "parseFragment", "getTreeBuilder", "getTreeWalker", "serialize"] + +__version__: Final[str] diff --git a/stubs/html5lib/html5lib/_ihatexml.pyi b/stubs/html5lib/html5lib/_ihatexml.pyi index cd710c885815..44115cfbab7a 100644 --- a/stubs/html5lib/html5lib/_ihatexml.pyi +++ b/stubs/html5lib/html5lib/_ihatexml.pyi @@ -1,39 +1,41 @@ -from typing import Any +import re +from _typeshed import Incomplete +from collections.abc import Iterable baseChar: str ideographic: str combiningCharacter: str digit: str extender: str -letter: Any -name: Any -nameFirst: Any -reChar: Any -reCharRange: Any +letter: str +name: str +nameFirst: str +reChar: re.Pattern[str] +reCharRange: re.Pattern[str] -def charStringToList(chars): ... -def normaliseCharList(charList): ... +def charStringToList(chars: str) -> list[str]: ... +def normaliseCharList(charList: Iterable[str]) -> list[str]: ... -max_unicode: Any +max_unicode: int -def missingRanges(charList): ... +def missingRanges(charList: Iterable[str]) -> list[str]: ... def listToRegexpStr(charList): ... -def hexToInt(hex_str): ... -def escapeRegexp(string): ... +def hexToInt(hex_str: str | bytes | bytearray) -> int: ... +def escapeRegexp(string: str) -> str: ... -nonXmlNameBMPRegexp: Any -nonXmlNameFirstBMPRegexp: Any -nonPubidCharRegexp: Any +nonXmlNameBMPRegexp: re.Pattern[str] +nonXmlNameFirstBMPRegexp: re.Pattern[str] +nonPubidCharRegexp: re.Pattern[str] class InfosetFilter: - replacementRegexp: Any - dropXmlnsLocalName: Any - dropXmlnsAttrNs: Any - preventDoubleDashComments: Any - preventDashAtCommentEnd: Any - replaceFormFeedCharacters: Any - preventSingleQuotePubid: Any - replaceCache: Any + replacementRegexp: re.Pattern[str] + dropXmlnsLocalName: Incomplete + dropXmlnsAttrNs: Incomplete + preventDoubleDashComments: Incomplete + preventDashAtCommentEnd: Incomplete + replaceFormFeedCharacters: Incomplete + preventSingleQuotePubid: Incomplete + replaceCache: Incomplete def __init__( self, dropXmlnsLocalName: bool = False, diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi index 10759fad6cd5..cfd1b2f015c9 100644 --- a/stubs/html5lib/html5lib/_inputstream.pyi +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -1,6 +1,6 @@ -from _typeshed import SupportsRead +from _typeshed import Incomplete, SupportsRead from codecs import CodecInfo -from typing import Any, Protocol, overload +from typing import Protocol, overload from typing_extensions import TypeAlias # Is actually webencodings.Encoding @@ -13,20 +13,20 @@ _UnicodeInputStream: TypeAlias = str | SupportsRead[str] _BinaryInputStream: TypeAlias = bytes | SupportsRead[bytes] _InputStream: TypeAlias = _UnicodeInputStream | _BinaryInputStream # noqa: Y047 # used in other files -spaceCharactersBytes: Any -asciiLettersBytes: Any -asciiUppercaseBytes: Any -spacesAngleBrackets: Any +spaceCharactersBytes: Incomplete +asciiLettersBytes: Incomplete +asciiUppercaseBytes: Incomplete +spacesAngleBrackets: Incomplete invalid_unicode_no_surrogate: str -invalid_unicode_re: Any -non_bmp_invalid_codepoints: Any -ascii_punctuation_re: Any -charsUntilRegEx: Any +invalid_unicode_re: Incomplete +non_bmp_invalid_codepoints: Incomplete +ascii_punctuation_re: Incomplete +charsUntilRegEx: Incomplete class BufferedStream: - stream: Any - buffer: Any - position: Any + stream: Incomplete + buffer: Incomplete + position: Incomplete def __init__(self, stream) -> None: ... def tell(self): ... def seek(self, pos) -> None: ... @@ -47,10 +47,10 @@ def HTMLInputStream( ) -> HTMLBinaryInputStream: ... class HTMLUnicodeInputStream: - reportCharacterErrors: Any - newLines: Any + reportCharacterErrors: Incomplete + newLines: Incomplete charEncoding: tuple[_Encoding, str] - dataStream: Any + dataStream: Incomplete def __init__(self, source: _UnicodeInputStream) -> None: ... chunk: str chunkSize: int @@ -69,14 +69,14 @@ class HTMLUnicodeInputStream: def unget(self, char) -> None: ... class HTMLBinaryInputStream(HTMLUnicodeInputStream): - rawStream: Any + rawStream: Incomplete numBytesMeta: int numBytesChardet: int - override_encoding: Any - transport_encoding: Any - same_origin_parent_encoding: Any - likely_encoding: Any - default_encoding: Any + override_encoding: Incomplete + transport_encoding: Incomplete + same_origin_parent_encoding: Incomplete + likely_encoding: Incomplete + default_encoding: Incomplete charEncoding: tuple[_Encoding, str] def __init__( self, @@ -88,7 +88,7 @@ class HTMLBinaryInputStream(HTMLUnicodeInputStream): default_encoding: str = "windows-1252", useChardet: bool = True, ) -> None: ... - dataStream: Any + dataStream: Incomplete def reset(self) -> None: ... def openStream(self, source): ... def determineEncoding(self, chardet: bool = True): ... @@ -105,7 +105,7 @@ class EncodingBytes(bytes): def previous(self): ... def setPosition(self, position) -> None: ... def getPosition(self): ... - position: Any + position: Incomplete def getCurrentByte(self): ... @property def currentByte(self): ... @@ -115,8 +115,8 @@ class EncodingBytes(bytes): def jumpTo(self, bytes): ... class EncodingParser: - data: Any - encoding: Any + data: Incomplete + encoding: Incomplete def __init__(self, data) -> None: ... def getEncoding(self): ... def handleComment(self): ... @@ -128,7 +128,7 @@ class EncodingParser: def getAttribute(self): ... class ContentAttrParser: - data: Any + data: Incomplete def __init__(self, data) -> None: ... def parse(self): ... diff --git a/stubs/html5lib/html5lib/_tokenizer.pyi b/stubs/html5lib/html5lib/_tokenizer.pyi index e999fbcde4cf..22316b1112b5 100644 --- a/stubs/html5lib/html5lib/_tokenizer.pyi +++ b/stubs/html5lib/html5lib/_tokenizer.pyi @@ -1,20 +1,20 @@ -from typing import Any +from _typeshed import Incomplete from ._inputstream import _InputStream -entitiesTrie: Any +entitiesTrie: Incomplete attributeMap = dict class HTMLTokenizer: - stream: Any - parser: Any + stream: Incomplete + parser: Incomplete escapeFlag: bool - lastFourChars: Any - state: Any + lastFourChars: Incomplete + state: Incomplete escape: bool - currentToken: Any + currentToken: Incomplete def __init__(self, stream: _InputStream, parser=None, **kwargs) -> None: ... - tokenQueue: Any + tokenQueue: Incomplete def __iter__(self): ... def consumeNumberEntity(self, isHex): ... def consumeEntity(self, allowedChar=None, fromAttribute: bool = False) -> None: ... diff --git a/stubs/html5lib/html5lib/_trie/__init__.pyi b/stubs/html5lib/html5lib/_trie/__init__.pyi index 7095d84cbea4..3b0ea9a093bf 100644 --- a/stubs/html5lib/html5lib/_trie/__init__.pyi +++ b/stubs/html5lib/html5lib/_trie/__init__.pyi @@ -1 +1,3 @@ from .py import Trie as Trie + +__all__ = ["Trie"] diff --git a/stubs/html5lib/html5lib/_trie/_base.pyi b/stubs/html5lib/html5lib/_trie/_base.pyi index 7016028a2417..45725be511b6 100644 --- a/stubs/html5lib/html5lib/_trie/_base.pyi +++ b/stubs/html5lib/html5lib/_trie/_base.pyi @@ -1,8 +1,8 @@ +from _typeshed import Incomplete from abc import ABCMeta from collections.abc import Mapping -from typing import Any -class Trie(Mapping[Any, Any], metaclass=ABCMeta): +class Trie(Mapping[Incomplete, Incomplete], metaclass=ABCMeta): def keys(self, prefix=None): ... def has_keys_with_prefix(self, prefix): ... def longest_prefix(self, prefix): ... diff --git a/stubs/html5lib/html5lib/_utils.pyi b/stubs/html5lib/html5lib/_utils.pyi index 7cc3edba3c64..f41afba04144 100644 --- a/stubs/html5lib/html5lib/_utils.pyi +++ b/stubs/html5lib/html5lib/_utils.pyi @@ -1,17 +1,27 @@ +import xml.etree.ElementTree as default_etree +from _typeshed import Incomplete from collections.abc import Mapping -from typing import Any + +__all__ = [ + "default_etree", + "MethodDispatcher", + "isSurrogatePair", + "surrogatePairToCodepoint", + "moduleFactoryFactory", + "supports_lone_surrogates", +] supports_lone_surrogates: bool -class MethodDispatcher(dict[Any, Any]): - default: Any +class MethodDispatcher(dict[Incomplete, Incomplete]): + default: Incomplete def __init__(self, items=()) -> None: ... def __getitem__(self, key): ... def __get__(self, instance, owner=None): ... -class BoundMethodDispatcher(Mapping[Any, Any]): - instance: Any - dispatcher: Any +class BoundMethodDispatcher(Mapping[Incomplete, Incomplete]): + instance: Incomplete + dispatcher: Incomplete def __init__(self, instance, dispatcher) -> None: ... def __getitem__(self, key): ... def get(self, key, default): ... # type: ignore[override] diff --git a/stubs/html5lib/html5lib/constants.pyi b/stubs/html5lib/html5lib/constants.pyi index b8a3ac8f1cdd..a0e12fbff98e 100644 --- a/stubs/html5lib/html5lib/constants.pyi +++ b/stubs/html5lib/html5lib/constants.pyi @@ -1,37 +1,37 @@ -from typing import Any +from _typeshed import Incomplete -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 +EOF: Incomplete +E: dict[str, str] +namespaces: dict[str, str] +scopingElements: frozenset[tuple[str, str]] +formattingElements: frozenset[tuple[str, str]] +specialElements: frozenset[tuple[str, str]] +htmlIntegrationPointElements: frozenset[tuple[str, str]] +mathmlTextIntegrationPointElements: frozenset[tuple[str, str]] +adjustSVGAttributes: dict[str, str] +adjustMathMLAttributes: dict[str, str] +adjustForeignAttributes: dict[str, tuple[str, str, str] | tuple[None, str, str]] +unadjustForeignAttributes: dict[tuple[str, str], str] +spaceCharacters: frozenset[str] +tableInsertModeElements: frozenset[str] +asciiLowercase: frozenset[str] +asciiUppercase: frozenset[str] +asciiLetters: frozenset[str] +digits: frozenset[str] +hexDigits: frozenset[str] +asciiUpper2Lower: dict[int, int] +headingElements: tuple[str, ...] +voidElements: frozenset[str] +cdataElements: frozenset[str] +rcdataElements: frozenset[str] +booleanAttributes: dict[str, frozenset[str]] +entitiesWindows1252: tuple[int, ...] +xmlEntities: frozenset[str] +entities: dict[str, str] +replacementCharacters: dict[int, str] +tokenTypes: dict[str, int] +tagTokenTypes: frozenset[int] +prefixes: dict[str, str] class DataLossWarning(UserWarning): ... class _ReparseException(Exception): ... diff --git a/stubs/html5lib/html5lib/filters/base.pyi b/stubs/html5lib/html5lib/filters/base.pyi index 166f2040425e..82773fd9124f 100644 --- a/stubs/html5lib/html5lib/filters/base.pyi +++ b/stubs/html5lib/html5lib/filters/base.pyi @@ -1,7 +1,7 @@ -from typing import Any +from _typeshed import Incomplete class Filter: - source: Any + source: Incomplete def __init__(self, source) -> None: ... def __iter__(self): ... def __getattr__(self, name: str): ... diff --git a/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi b/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi index 9cde8fde35bc..030cd63753df 100644 --- a/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi +++ b/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi @@ -1,8 +1,6 @@ -from typing import Any - from . import base class Filter(base.Filter): - encoding: Any - def __init__(self, source, encoding) -> None: ... + encoding: str | None + def __init__(self, source, encoding: str | None) -> None: ... def __iter__(self): ... diff --git a/stubs/html5lib/html5lib/filters/lint.pyi b/stubs/html5lib/html5lib/filters/lint.pyi index 9aba9592a96f..39629c8696d6 100644 --- a/stubs/html5lib/html5lib/filters/lint.pyi +++ b/stubs/html5lib/html5lib/filters/lint.pyi @@ -1,8 +1,8 @@ -from typing import Any - from . import base +spaceCharacters: str + class Filter(base.Filter): - require_matching_tags: Any + require_matching_tags: bool def __init__(self, source, require_matching_tags: bool = True) -> None: ... def __iter__(self): ... diff --git a/stubs/html5lib/html5lib/filters/optionaltags.pyi b/stubs/html5lib/html5lib/filters/optionaltags.pyi index 5d53a467e4a5..81045a0e068f 100644 --- a/stubs/html5lib/html5lib/filters/optionaltags.pyi +++ b/stubs/html5lib/html5lib/filters/optionaltags.pyi @@ -1,7 +1,10 @@ +from _typeshed import Incomplete +from collections.abc import Generator + from . import base class Filter(base.Filter): - def slider(self) -> None: ... + def slider(self) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... def __iter__(self): ... - def is_optional_start(self, tagname, previous, next): ... - def is_optional_end(self, tagname, next): ... + def is_optional_start(self, tagname: str, previous, next) -> bool: ... + def is_optional_end(self, tagname: str, next) -> bool: ... diff --git a/stubs/html5lib/html5lib/filters/sanitizer.pyi b/stubs/html5lib/html5lib/filters/sanitizer.pyi index 176e81a01796..7761f2719a5a 100644 --- a/stubs/html5lib/html5lib/filters/sanitizer.pyi +++ b/stubs/html5lib/html5lib/filters/sanitizer.pyi @@ -1,34 +1,51 @@ -from typing import Any +import re +from collections.abc import Iterable +from typing_extensions import deprecated from . import base +__all__ = ["Filter"] + +allowed_elements: frozenset[tuple[str, str]] +allowed_attributes: frozenset[tuple[None, str] | tuple[str, str]] +attr_val_is_uri: frozenset[tuple[None, str] | tuple[str, str]] +svg_attr_val_allows_ref: frozenset[tuple[None, str]] +svg_allow_local_href: frozenset[tuple[None, str]] +allowed_css_properties: frozenset[str] +allowed_css_keywords: frozenset[str] +allowed_svg_properties: frozenset[str] +allowed_protocols: frozenset[str] +allowed_content_types: frozenset[str] +data_content_type: re.Pattern[str] + +@deprecated("html5lib's sanitizer is deprecated; see https://github.com/html5lib/html5lib-python/issues/443") 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 + allowed_elements: Iterable[tuple[str | None, str]] + allowed_attributes: Iterable[tuple[str | None, str]] + allowed_css_properties: Iterable[str] + allowed_css_keywords: Iterable[str] + allowed_svg_properties: Iterable[str] + allowed_protocols: Iterable[str] + allowed_content_types: Iterable[str] + attr_val_is_uri: Iterable[tuple[str | None, str]] + svg_attr_val_allows_ref: Iterable[tuple[str | None, str]] + svg_allow_local_href: Iterable[tuple[str | None, str]] 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=..., + allowed_elements: Iterable[tuple[str | None, str]] = ..., + allowed_attributes: Iterable[tuple[str | None, str]] = ..., + allowed_css_properties: Iterable[str] = ..., + allowed_css_keywords: Iterable[str] = ..., + allowed_svg_properties: Iterable[str] = ..., + allowed_protocols: Iterable[str] = ..., + allowed_content_types: Iterable[str] = ..., + attr_val_is_uri: Iterable[tuple[str | None, str]] = ..., + svg_attr_val_allows_ref: Iterable[tuple[str | None, str]] = ..., + svg_allow_local_href: Iterable[tuple[str | None, str]] = ..., ) -> None: ... def __iter__(self): ... def sanitize_token(self, token): ... def allowed_token(self, token): ... def disallowed_token(self, token): ... - def sanitize_css(self, style): ... + def sanitize_css(self, style: str) -> str: ... diff --git a/stubs/html5lib/html5lib/filters/whitespace.pyi b/stubs/html5lib/html5lib/filters/whitespace.pyi index 117aaf6411a0..39f818100c7a 100644 --- a/stubs/html5lib/html5lib/filters/whitespace.pyi +++ b/stubs/html5lib/html5lib/filters/whitespace.pyi @@ -1,11 +1,12 @@ -from typing import Any +import re from . import base -SPACES_REGEX: Any +spaceCharacters: str +SPACES_REGEX: re.Pattern[str] class Filter(base.Filter): - spacePreserveElements: Any + spacePreserveElements: frozenset[str] def __iter__(self): ... -def collapse_spaces(text): ... +def collapse_spaces(text: str) -> str: ... diff --git a/stubs/html5lib/html5lib/html5parser.pyi b/stubs/html5lib/html5lib/html5parser.pyi index 2e38eaea5688..456fd35a5f0e 100644 --- a/stubs/html5lib/html5lib/html5parser.pyi +++ b/stubs/html5lib/html5lib/html5parser.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import Any, Literal, overload +from typing import Literal, overload from xml.etree.ElementTree import Element from ._inputstream import _InputStream @@ -18,18 +18,18 @@ def method_decorator_metaclass(function): ... class HTMLParser: strict: bool - tree: Any + tree: Incomplete errors: list[Incomplete] - phases: Any + phases: Incomplete def __init__(self, tree=None, strict: bool = False, namespaceHTMLElements: bool = True, debug: bool = False) -> None: ... firstStartTag: bool - log: Any + log: Incomplete compatMode: str container: str - innerHTML: Any - phase: Any - lastPhase: Any - beforeRCDataPhase: Any + innerHTML: Incomplete + phase: Incomplete + lastPhase: Incomplete + beforeRCDataPhase: Incomplete framesetOK: bool tokenizer: HTMLTokenizer def reset(self) -> None: ... @@ -46,7 +46,7 @@ class HTMLParser: def adjustForeignAttributes(self, token) -> None: ... def reparseTokenNormal(self, token) -> None: ... def resetInsertionMode(self) -> None: ... - originalPhase: Any + originalPhase: Incomplete def parseRCDataRawtext(self, token, contentType) -> None: ... def getPhases(debug): ... diff --git a/stubs/html5lib/html5lib/serializer.pyi b/stubs/html5lib/html5lib/serializer.pyi index c17b2205ae43..e7232e2e1d11 100644 --- a/stubs/html5lib/html5lib/serializer.pyi +++ b/stubs/html5lib/html5lib/serializer.pyi @@ -1,6 +1,9 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import Any, overload +from typing import overload + +k: str +v: str | int def htmlentityreplace_errors(exc: Exception) -> tuple[str | bytes, int]: ... @overload @@ -25,14 +28,14 @@ class HTMLSerializer: inject_meta_charset: bool strip_whitespace: bool sanitize: bool - options: Any - errors: Any + options: Incomplete + errors: Incomplete strict: bool def __init__(self, **kwargs) -> None: ... def encode(self, string): ... def encodeStrict(self, string): ... - encoding: Any - def serialize(self, treewalker, encoding=None) -> Generator[Incomplete, None, None]: ... + encoding: Incomplete + def serialize(self, treewalker, encoding=None) -> Generator[Incomplete]: ... def render(self, treewalker, encoding=None): ... def serializeError(self, data: str = "XXX ERROR MESSAGE NEEDED") -> None: ... diff --git a/stubs/html5lib/html5lib/treeadapters/__init__.pyi b/stubs/html5lib/html5lib/treeadapters/__init__.pyi index bf1267485d4b..49b1ebb296a2 100644 --- a/stubs/html5lib/html5lib/treeadapters/__init__.pyi +++ b/stubs/html5lib/html5lib/treeadapters/__init__.pyi @@ -1 +1,3 @@ from . import genshi as genshi, sax as sax + +__all__ = ["sax", "genshi"] diff --git a/stubs/html5lib/html5lib/treeadapters/sax.pyi b/stubs/html5lib/html5lib/treeadapters/sax.pyi index 87ebcb1cb930..3ac32ef19361 100644 --- a/stubs/html5lib/html5lib/treeadapters/sax.pyi +++ b/stubs/html5lib/html5lib/treeadapters/sax.pyi @@ -1,5 +1,6 @@ -from typing import Any - -prefix_mapping: Any +prefix: str | None +localName: str +namespace: str +prefix_mapping: dict[str, str] def to_sax(walker, handler) -> None: ... diff --git a/stubs/html5lib/html5lib/treebuilders/__init__.pyi b/stubs/html5lib/html5lib/treebuilders/__init__.pyi index 703478287fe5..7fc1af410d92 100644 --- a/stubs/html5lib/html5lib/treebuilders/__init__.pyi +++ b/stubs/html5lib/html5lib/treebuilders/__init__.pyi @@ -1,5 +1,5 @@ -from typing import Any +from typing import Literal -treeBuilderCache: Any +treeBuilderCache: dict[str, type] -def getTreeBuilder(treeType, implementation=None, **kwargs): ... +def getTreeBuilder(treeType: Literal["dom", "etree", "lxml"], implementation=None, **kwargs): ... diff --git a/stubs/html5lib/html5lib/treebuilders/base.pyi b/stubs/html5lib/html5lib/treebuilders/base.pyi index 577b92327b9c..59137fe3239f 100644 --- a/stubs/html5lib/html5lib/treebuilders/base.pyi +++ b/stubs/html5lib/html5lib/treebuilders/base.pyi @@ -1,15 +1,15 @@ -from typing import Any +from _typeshed import Incomplete -Marker: Any -listElementsMap: Any +Marker: Incomplete +listElementsMap: dict[str | None, tuple[frozenset[tuple[str, str]], bool]] class Node: - name: Any - parent: Any - value: Any - attributes: Any - childNodes: Any - def __init__(self, name) -> None: ... + name: str + parent: Incomplete + value: Incomplete + attributes: Incomplete + childNodes: Incomplete + def __init__(self, name: str) -> None: ... def appendChild(self, node) -> None: ... def insertText(self, data, insertBefore=None) -> None: ... def insertBefore(self, node, refNode) -> None: ... @@ -18,24 +18,24 @@ class Node: def cloneNode(self) -> None: ... def hasContent(self) -> None: ... -class ActiveFormattingElements(list[Any]): +class ActiveFormattingElements(list[Incomplete]): def append(self, node) -> None: ... - def nodesEqual(self, node1, node2): ... + def nodesEqual(self, node1, node2) -> bool: ... 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 + documentClass: Incomplete + elementClass: Incomplete + commentClass: Incomplete + doctypeClass: Incomplete + fragmentClass: Incomplete + defaultNamespace: str | None + def __init__(self, namespaceHTMLElements: bool | None) -> None: ... + openElements: Incomplete + activeFormattingElements: Incomplete + headPointer: Incomplete + formPointer: Incomplete insertFromTable: bool - document: Any + document: Incomplete def reset(self) -> None: ... def elementInScope(self, target, variant=None): ... def reconstructActiveFormattingElements(self) -> None: ... @@ -52,4 +52,4 @@ class TreeBuilder: def generateImpliedEndTags(self, exclude=None) -> None: ... def getDocument(self): ... def getFragment(self): ... - def testSerializer(self, node) -> None: ... + def testSerializer(self, node): ... diff --git a/stubs/html5lib/html5lib/treebuilders/dom.pyi b/stubs/html5lib/html5lib/treebuilders/dom.pyi index 12de3344d248..d8049c383cf1 100644 --- a/stubs/html5lib/html5lib/treebuilders/dom.pyi +++ b/stubs/html5lib/html5lib/treebuilders/dom.pyi @@ -1,5 +1,7 @@ -from typing import Any +from _typeshed import Incomplete +from collections.abc import Callable +from types import ModuleType -def getDomBuilder(DomImplementation): ... +def getDomBuilder(DomImplementation) -> dict[str, Incomplete]: ... -getDomModule: Any +getDomModule: Callable[..., ModuleType] diff --git a/stubs/html5lib/html5lib/treebuilders/etree.pyi b/stubs/html5lib/html5lib/treebuilders/etree.pyi index 948651dabd8c..b9dfabb88835 100644 --- a/stubs/html5lib/html5lib/treebuilders/etree.pyi +++ b/stubs/html5lib/html5lib/treebuilders/etree.pyi @@ -1,7 +1,10 @@ -from typing import Any +import re +from _typeshed import Incomplete +from collections.abc import Callable +from types import ModuleType -tag_regexp: Any +tag_regexp: re.Pattern[str] -def getETreeBuilder(ElementTreeImplementation, fullTree: bool = False): ... +def getETreeBuilder(ElementTreeImplementation, fullTree: bool = False) -> dict[str, Incomplete]: ... -getETreeModule: Any +getETreeModule: Callable[..., ModuleType] diff --git a/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi b/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi index 3bf5bea6481f..665eb117d358 100644 --- a/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi +++ b/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi @@ -1,15 +1,16 @@ -from typing import Any +import re +from _typeshed import Incomplete from . import base fullTree: bool -tag_regexp: Any -comment_type: Any +tag_regexp: re.Pattern[str] +comment_type: Incomplete class DocumentType: - name: Any - publicId: Any - systemId: Any + name: Incomplete + publicId: Incomplete + systemId: Incomplete def __init__(self, name, publicId, systemId) -> None: ... class Document: @@ -18,21 +19,21 @@ class Document: @property def childNodes(self): ... -def testSerializer(element): ... -def tostring(element): ... +def testSerializer(element) -> str: ... +def tostring(element) -> str: ... class TreeBuilder(base.TreeBuilder): - documentClass: Any - doctypeClass: Any - elementClass: Any - commentClass: Any - fragmentClass: Any - implementation: Any - namespaceHTMLElements: Any + documentClass: Incomplete + doctypeClass: Incomplete + elementClass: Incomplete + commentClass: Incomplete + fragmentClass: Incomplete + implementation: Incomplete + namespaceHTMLElements: Incomplete def __init__(self, namespaceHTMLElements, fullTree: bool = False): ... - insertComment: Any - initial_comments: Any - doctype: Any + insertComment: Incomplete + initial_comments: Incomplete + doctype: Incomplete def reset(self) -> None: ... def testSerializer(self, element): ... def getDocument(self): ... @@ -40,5 +41,5 @@ class TreeBuilder(base.TreeBuilder): def insertDoctype(self, token) -> None: ... def insertCommentInitial(self, data, parent=None) -> None: ... def insertCommentMain(self, data, parent=None) -> None: ... - document: Any + document: Incomplete def insertRoot(self, token) -> None: ... diff --git a/stubs/html5lib/html5lib/treewalkers/__init__.pyi b/stubs/html5lib/html5lib/treewalkers/__init__.pyi index 62d6f2a9f5fc..247912e69830 100644 --- a/stubs/html5lib/html5lib/treewalkers/__init__.pyi +++ b/stubs/html5lib/html5lib/treewalkers/__init__.pyi @@ -1,2 +1,7 @@ -def getTreeWalker(treeType, implementation=None, **kwargs): ... -def pprint(walker): ... +from types import ModuleType + +__all__ = ["getTreeWalker", "pprint"] + +def getTreeWalker(treeType: str, implementation: ModuleType | None = None, **kwargs): ... +def concatenateCharacterTokens(tokens): ... +def pprint(walker) -> str: ... diff --git a/stubs/html5lib/html5lib/treewalkers/base.pyi b/stubs/html5lib/html5lib/treewalkers/base.pyi index 3e6649735266..2ef37965b6d2 100644 --- a/stubs/html5lib/html5lib/treewalkers/base.pyi +++ b/stubs/html5lib/html5lib/treewalkers/base.pyi @@ -1,15 +1,18 @@ -from typing import Any +from _typeshed import Incomplete -DOCUMENT: Any -DOCTYPE: Any -TEXT: Any -ELEMENT: Any -COMMENT: Any -ENTITY: Any +__all__ = ["DOCUMENT", "DOCTYPE", "TEXT", "ELEMENT", "COMMENT", "ENTITY", "UNKNOWN", "TreeWalker", "NonRecursiveTreeWalker"] + +DOCUMENT: int +DOCTYPE: int +TEXT: int +ELEMENT: int +COMMENT: int +ENTITY: int UNKNOWN: str +spaceCharacters: str class TreeWalker: - tree: Any + tree: Incomplete def __init__(self, tree) -> None: ... def __iter__(self): ... def error(self, msg): ... diff --git a/stubs/html5lib/html5lib/treewalkers/etree.pyi b/stubs/html5lib/html5lib/treewalkers/etree.pyi index 33f6d800214f..94878061a818 100644 --- a/stubs/html5lib/html5lib/treewalkers/etree.pyi +++ b/stubs/html5lib/html5lib/treewalkers/etree.pyi @@ -1,7 +1,9 @@ -from typing import Any +import re +from collections.abc import Callable +from types import ModuleType -tag_regexp: Any +tag_regexp: re.Pattern[str] def getETreeBuilder(ElementTreeImplementation): ... -getETreeModule: Any +getETreeModule: Callable[..., ModuleType] diff --git a/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi b/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi index 6ef2c48379f5..4071bb068650 100644 --- a/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi +++ b/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi @@ -1,40 +1,44 @@ -from typing import Any +from _typeshed import Incomplete +from typing import SupportsIndex, overload from .base import NonRecursiveTreeWalker -def ensure_str(s): ... +@overload +def ensure_str(s: None) -> None: ... +@overload +def ensure_str(s: str | bytes | bytearray) -> str: ... class Root: - elementtree: Any - children: Any - text: Any - tail: Any + elementtree: Incomplete + children: list[Incomplete] + text: str | None + tail: str | None def __init__(self, et) -> None: ... - def __getitem__(self, key): ... + def __getitem__(self, key: SupportsIndex): ... def getnext(self) -> None: ... def __len__(self) -> int: ... class Doctype: - root_node: Any - name: Any - public_id: Any - system_id: Any - text: Any - tail: Any + root_node: Incomplete + name: Incomplete + public_id: Incomplete + system_id: Incomplete + text: Incomplete + tail: Incomplete def __init__(self, root_node, name, public_id, system_id) -> None: ... def getnext(self): ... class FragmentRoot(Root): - children: Any - text: Any + children: Incomplete + text: Incomplete def __init__(self, children) -> None: ... def getnext(self) -> None: ... class FragmentWrapper: - root_node: Any - obj: Any - text: Any - tail: Any + root_node: Incomplete + obj: Incomplete + text: Incomplete + tail: Incomplete def __init__(self, fragment_root, obj) -> None: ... def __getattr__(self, name: str): ... def getnext(self): ... @@ -45,8 +49,8 @@ class FragmentWrapper: def __len__(self) -> int: ... class TreeWalker(NonRecursiveTreeWalker): - fragmentChildren: Any - filter: Any + fragmentChildren: Incomplete + filter: Incomplete def __init__(self, tree) -> None: ... def getNodeDetails(self, node): ... def getFirstChild(self, node): ...