mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
[stdlib] Add missing Final (#14613)
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
from typing import Literal
|
||||
from typing import Final
|
||||
from xml.dom.minidom import Node
|
||||
|
||||
class NodeFilter:
|
||||
FILTER_ACCEPT: Literal[1]
|
||||
FILTER_REJECT: Literal[2]
|
||||
FILTER_SKIP: Literal[3]
|
||||
FILTER_ACCEPT: Final = 1
|
||||
FILTER_REJECT: Final = 2
|
||||
FILTER_SKIP: Final = 3
|
||||
|
||||
SHOW_ALL: int
|
||||
SHOW_ELEMENT: int
|
||||
SHOW_ATTRIBUTE: int
|
||||
SHOW_TEXT: int
|
||||
SHOW_CDATA_SECTION: int
|
||||
SHOW_ENTITY_REFERENCE: int
|
||||
SHOW_ENTITY: int
|
||||
SHOW_PROCESSING_INSTRUCTION: int
|
||||
SHOW_COMMENT: int
|
||||
SHOW_DOCUMENT: int
|
||||
SHOW_DOCUMENT_TYPE: int
|
||||
SHOW_DOCUMENT_FRAGMENT: int
|
||||
SHOW_NOTATION: int
|
||||
SHOW_ALL: Final = 0xFFFFFFFF
|
||||
SHOW_ELEMENT: Final = 0x00000001
|
||||
SHOW_ATTRIBUTE: Final = 0x00000002
|
||||
SHOW_TEXT: Final = 0x00000004
|
||||
SHOW_CDATA_SECTION: Final = 0x00000008
|
||||
SHOW_ENTITY_REFERENCE: Final = 0x00000010
|
||||
SHOW_ENTITY: Final = 0x00000020
|
||||
SHOW_PROCESSING_INSTRUCTION: Final = 0x00000040
|
||||
SHOW_COMMENT: Final = 0x00000080
|
||||
SHOW_DOCUMENT: Final = 0x00000100
|
||||
SHOW_DOCUMENT_TYPE: Final = 0x00000200
|
||||
SHOW_DOCUMENT_FRAGMENT: Final = 0x00000400
|
||||
SHOW_NOTATION: Final = 0x00000800
|
||||
def acceptNode(self, node: Node) -> int: ...
|
||||
|
||||
+16
-16
@@ -3,18 +3,18 @@ from typing import Any, Final, Literal
|
||||
from .domreg import getDOMImplementation as getDOMImplementation, registerDOMImplementation as registerDOMImplementation
|
||||
|
||||
class Node:
|
||||
ELEMENT_NODE: Literal[1]
|
||||
ATTRIBUTE_NODE: Literal[2]
|
||||
TEXT_NODE: Literal[3]
|
||||
CDATA_SECTION_NODE: Literal[4]
|
||||
ENTITY_REFERENCE_NODE: Literal[5]
|
||||
ENTITY_NODE: Literal[6]
|
||||
PROCESSING_INSTRUCTION_NODE: Literal[7]
|
||||
COMMENT_NODE: Literal[8]
|
||||
DOCUMENT_NODE: Literal[9]
|
||||
DOCUMENT_TYPE_NODE: Literal[10]
|
||||
DOCUMENT_FRAGMENT_NODE: Literal[11]
|
||||
NOTATION_NODE: Literal[12]
|
||||
ELEMENT_NODE: Final = 1
|
||||
ATTRIBUTE_NODE: Final = 2
|
||||
TEXT_NODE: Final = 3
|
||||
CDATA_SECTION_NODE: Final = 4
|
||||
ENTITY_REFERENCE_NODE: Final = 5
|
||||
ENTITY_NODE: Final = 6
|
||||
PROCESSING_INSTRUCTION_NODE: Final = 7
|
||||
COMMENT_NODE: Final = 8
|
||||
DOCUMENT_NODE: Final = 9
|
||||
DOCUMENT_TYPE_NODE: Final = 10
|
||||
DOCUMENT_FRAGMENT_NODE: Final = 11
|
||||
NOTATION_NODE: Final = 12
|
||||
|
||||
# ExceptionCode
|
||||
INDEX_SIZE_ERR: Final = 1
|
||||
@@ -88,10 +88,10 @@ class ValidationErr(DOMException):
|
||||
code: Literal[16]
|
||||
|
||||
class UserDataHandler:
|
||||
NODE_CLONED: Literal[1]
|
||||
NODE_IMPORTED: Literal[2]
|
||||
NODE_DELETED: Literal[3]
|
||||
NODE_RENAMED: Literal[4]
|
||||
NODE_CLONED: Final = 1
|
||||
NODE_IMPORTED: Final = 2
|
||||
NODE_DELETED: Final = 3
|
||||
NODE_RENAMED: Final = 4
|
||||
|
||||
XML_NAMESPACE: Final = "http://www.w3.org/XML/1998/namespace"
|
||||
XMLNS_NAMESPACE: Final = "http://www.w3.org/2000/xmlns/"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from _typeshed import ReadableBuffer, SupportsRead
|
||||
from typing import Any, NoReturn
|
||||
from typing import Any, Final, NoReturn
|
||||
from typing_extensions import TypeAlias
|
||||
from xml.dom.minidom import Document, DocumentFragment, DOMImplementation, Element, Node, TypeInfo
|
||||
from xml.dom.xmlbuilder import DOMBuilderFilter, Options
|
||||
@@ -7,13 +7,13 @@ from xml.parsers.expat import XMLParserType
|
||||
|
||||
_Model: TypeAlias = tuple[int, int, str | None, tuple[Any, ...]] # same as in pyexpat
|
||||
|
||||
TEXT_NODE = Node.TEXT_NODE
|
||||
CDATA_SECTION_NODE = Node.CDATA_SECTION_NODE
|
||||
DOCUMENT_NODE = Node.DOCUMENT_NODE
|
||||
FILTER_ACCEPT = DOMBuilderFilter.FILTER_ACCEPT
|
||||
FILTER_REJECT = DOMBuilderFilter.FILTER_REJECT
|
||||
FILTER_SKIP = DOMBuilderFilter.FILTER_SKIP
|
||||
FILTER_INTERRUPT = DOMBuilderFilter.FILTER_INTERRUPT
|
||||
TEXT_NODE: Final = Node.TEXT_NODE
|
||||
CDATA_SECTION_NODE: Final = Node.CDATA_SECTION_NODE
|
||||
DOCUMENT_NODE: Final = Node.DOCUMENT_NODE
|
||||
FILTER_ACCEPT: Final = DOMBuilderFilter.FILTER_ACCEPT
|
||||
FILTER_REJECT: Final = DOMBuilderFilter.FILTER_REJECT
|
||||
FILTER_SKIP: Final = DOMBuilderFilter.FILTER_SKIP
|
||||
FILTER_INTERRUPT: Final = DOMBuilderFilter.FILTER_INTERRUPT
|
||||
theDOMImplementation: DOMImplementation
|
||||
|
||||
class ElementInfo:
|
||||
|
||||
@@ -99,7 +99,7 @@ class SAX2DOM(PullDOM):
|
||||
def ignorableWhitespace(self, chars: str) -> None: ...
|
||||
def characters(self, chars: str) -> None: ...
|
||||
|
||||
default_bufsize: int
|
||||
default_bufsize: Final[int]
|
||||
|
||||
def parse(
|
||||
stream_or_string: str | _SupportsReadClose[bytes] | _SupportsReadClose[str],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from _typeshed import SupportsRead
|
||||
from typing import Any, Literal, NoReturn
|
||||
from typing import Any, Final, Literal, NoReturn
|
||||
from xml.dom.minidom import Document, Node, _DOMErrorHandler
|
||||
|
||||
__all__ = ["DOMBuilder", "DOMEntityResolver", "DOMInputSource"]
|
||||
@@ -29,10 +29,10 @@ class DOMBuilder:
|
||||
entityResolver: DOMEntityResolver | None
|
||||
errorHandler: _DOMErrorHandler | None
|
||||
filter: DOMBuilderFilter | None
|
||||
ACTION_REPLACE: Literal[1]
|
||||
ACTION_APPEND_AS_CHILDREN: Literal[2]
|
||||
ACTION_INSERT_AFTER: Literal[3]
|
||||
ACTION_INSERT_BEFORE: Literal[4]
|
||||
ACTION_REPLACE: Final = 1
|
||||
ACTION_APPEND_AS_CHILDREN: Final = 2
|
||||
ACTION_INSERT_AFTER: Final = 3
|
||||
ACTION_INSERT_BEFORE: Final = 4
|
||||
def __init__(self) -> None: ...
|
||||
def setFeature(self, name: str, state: int) -> None: ...
|
||||
def supportsFeature(self, name: str) -> bool: ...
|
||||
@@ -56,10 +56,10 @@ class DOMInputSource:
|
||||
baseURI: str | None
|
||||
|
||||
class DOMBuilderFilter:
|
||||
FILTER_ACCEPT: Literal[1]
|
||||
FILTER_REJECT: Literal[2]
|
||||
FILTER_SKIP: Literal[3]
|
||||
FILTER_INTERRUPT: Literal[4]
|
||||
FILTER_ACCEPT: Final = 1
|
||||
FILTER_REJECT: Final = 2
|
||||
FILTER_SKIP: Final = 3
|
||||
FILTER_INTERRUPT: Final = 4
|
||||
whatToShow: int
|
||||
def acceptNode(self, element: Node) -> Literal[1, 2, 3, 4]: ...
|
||||
def startContainer(self, element: Node) -> Literal[1, 2, 3, 4]: ...
|
||||
@@ -72,8 +72,8 @@ class DocumentLS:
|
||||
def saveXML(self, snode: Node | None) -> str: ...
|
||||
|
||||
class DOMImplementationLS:
|
||||
MODE_SYNCHRONOUS: Literal[1]
|
||||
MODE_ASYNCHRONOUS: Literal[2]
|
||||
MODE_SYNCHRONOUS: Final = 1
|
||||
MODE_ASYNCHRONOUS: Final = 2
|
||||
def createDOMBuilder(self, mode: Literal[1], schemaType: None) -> DOMBuilder: ...
|
||||
def createDOMWriter(self) -> NoReturn: ...
|
||||
def createDOMInputSource(self) -> DOMInputSource: ...
|
||||
|
||||
@@ -9,9 +9,10 @@ class _Loader(Protocol):
|
||||
@overload
|
||||
def __call__(self, href: FileDescriptorOrPath, parse: Literal["text"], encoding: str | None = None) -> str: ...
|
||||
|
||||
XINCLUDE: Final[str]
|
||||
XINCLUDE_INCLUDE: Final[str]
|
||||
XINCLUDE_FALLBACK: Final[str]
|
||||
XINCLUDE: Final = "{http://www.w3.org/2001/XInclude}"
|
||||
|
||||
XINCLUDE_INCLUDE: Final = "{http://www.w3.org/2001/XInclude}include"
|
||||
XINCLUDE_FALLBACK: Final = "{http://www.w3.org/2001/XInclude}fallback"
|
||||
|
||||
DEFAULT_MAX_INCLUSION_DEPTH: Final = 6
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from collections.abc import Callable, Generator, Iterable
|
||||
from re import Pattern
|
||||
from typing import Any, Literal, TypeVar, overload
|
||||
from typing import Any, Final, Literal, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
from xml.etree.ElementTree import Element
|
||||
|
||||
xpath_tokenizer_re: Pattern[str]
|
||||
xpath_tokenizer_re: Final[Pattern[str]]
|
||||
|
||||
_Token: TypeAlias = tuple[str, str]
|
||||
_Next: TypeAlias = Callable[[], _Token]
|
||||
@@ -20,7 +20,7 @@ def prepare_descendant(next: _Next, token: _Token) -> _Callback | None: ...
|
||||
def prepare_parent(next: _Next, token: _Token) -> _Callback: ...
|
||||
def prepare_predicate(next: _Next, token: _Token) -> _Callback | None: ...
|
||||
|
||||
ops: dict[str, Callable[[_Next, _Token], _Callback | None]]
|
||||
ops: Final[dict[str, Callable[[_Next, _Token], _Callback | None]]]
|
||||
|
||||
class _SelectorContext:
|
||||
parent_map: dict[Element, Element] | None
|
||||
|
||||
@@ -181,7 +181,7 @@ class ElementTree(Generic[_Root]):
|
||||
) -> None: ...
|
||||
def write_c14n(self, file: _FileWriteC14N) -> None: ...
|
||||
|
||||
HTML_EMPTY: set[str]
|
||||
HTML_EMPTY: Final[set[str]]
|
||||
|
||||
def register_namespace(prefix: str, uri: str) -> None: ...
|
||||
@overload
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import ReadableBuffer, StrPath, SupportsRead, _T_co
|
||||
from collections.abc import Iterable
|
||||
from typing import Protocol, type_check_only
|
||||
from typing import Final, Protocol, type_check_only
|
||||
from typing_extensions import TypeAlias
|
||||
from xml.sax._exceptions import (
|
||||
SAXException as SAXException,
|
||||
@@ -19,7 +19,7 @@ class _SupportsReadClose(SupportsRead[_T_co], Protocol[_T_co]):
|
||||
|
||||
_Source: TypeAlias = StrPath | _SupportsReadClose[bytes] | _SupportsReadClose[str]
|
||||
|
||||
default_parser_list: list[str]
|
||||
default_parser_list: Final[list[str]]
|
||||
|
||||
def make_parser(parser_list: Iterable[str] = ()) -> XMLReader: ...
|
||||
def parse(source: _Source, handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import ReadableBuffer
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, Literal, overload
|
||||
from typing import Any, Final, Literal, overload
|
||||
from typing_extensions import TypeAlias
|
||||
from xml.sax import _Source, xmlreader
|
||||
from xml.sax.handler import _ContentHandlerProtocol
|
||||
@@ -11,7 +11,7 @@ if sys.version_info >= (3, 10):
|
||||
|
||||
_BoolType: TypeAlias = Literal[0, 1] | bool
|
||||
|
||||
version: str
|
||||
version: Final[str]
|
||||
AttributesImpl = xmlreader.AttributesImpl
|
||||
AttributesNSImpl = xmlreader.AttributesNSImpl
|
||||
|
||||
|
||||
+16
-16
@@ -1,8 +1,8 @@
|
||||
import sys
|
||||
from typing import Literal, NoReturn, Protocol, type_check_only
|
||||
from typing import Final, NoReturn, Protocol, type_check_only
|
||||
from xml.sax import xmlreader
|
||||
|
||||
version: str
|
||||
version: Final[str]
|
||||
|
||||
@type_check_only
|
||||
class _ErrorHandlerProtocol(Protocol): # noqa: Y046 # Protocol is not used
|
||||
@@ -62,20 +62,20 @@ class _EntityResolverProtocol(Protocol): # noqa: Y046 # Protocol is not used
|
||||
class EntityResolver:
|
||||
def resolveEntity(self, publicId: str | None, systemId: str) -> str: ...
|
||||
|
||||
feature_namespaces: str
|
||||
feature_namespace_prefixes: str
|
||||
feature_string_interning: str
|
||||
feature_validation: str
|
||||
feature_external_ges: str
|
||||
feature_external_pes: str
|
||||
all_features: list[str]
|
||||
property_lexical_handler: Literal["http://xml.org/sax/properties/lexical-handler"]
|
||||
property_declaration_handler: Literal["http://xml.org/sax/properties/declaration-handler"]
|
||||
property_dom_node: Literal["http://xml.org/sax/properties/dom-node"]
|
||||
property_xml_string: Literal["http://xml.org/sax/properties/xml-string"]
|
||||
property_encoding: Literal["http://www.python.org/sax/properties/encoding"]
|
||||
property_interning_dict: Literal["http://www.python.org/sax/properties/interning-dict"]
|
||||
all_properties: list[str]
|
||||
feature_namespaces: Final = "http://xml.org/sax/features/namespaces"
|
||||
feature_namespace_prefixes: Final = "http://xml.org/sax/features/namespace-prefixes"
|
||||
feature_string_interning: Final = "http://xml.org/sax/features/string-interning"
|
||||
feature_validation: Final = "http://xml.org/sax/features/validation"
|
||||
feature_external_ges: Final[str] # too long string
|
||||
feature_external_pes: Final[str] # too long string
|
||||
all_features: Final[list[str]]
|
||||
property_lexical_handler: Final = "http://xml.org/sax/properties/lexical-handler"
|
||||
property_declaration_handler: Final = "http://xml.org/sax/properties/declaration-handler"
|
||||
property_dom_node: Final = "http://xml.org/sax/properties/dom-node"
|
||||
property_xml_string: Final = "http://xml.org/sax/properties/xml-string"
|
||||
property_encoding: Final = "http://www.python.org/sax/properties/encoding"
|
||||
property_interning_dict: Final[str] # too long string
|
||||
all_properties: Final[list[str]]
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
class LexicalHandler:
|
||||
|
||||
Reference in New Issue
Block a user