mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-24 03:51:52 +08:00
Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from _typeshed.xml import DOMImplementation
|
||||
from typing import Callable, Dict, Iterable, Tuple
|
||||
from typing import Callable, Iterable
|
||||
|
||||
well_known_implementations: Dict[str, str]
|
||||
registered: Dict[str, Callable[[], DOMImplementation]]
|
||||
well_known_implementations: dict[str, str]
|
||||
registered: dict[str, Callable[[], DOMImplementation]]
|
||||
|
||||
def registerDOMImplementation(name: str, factory: Callable[[], DOMImplementation]) -> None: ...
|
||||
def getDOMImplementation(name: str | None = ..., features: str | Iterable[Tuple[str, str | None]] = ...) -> DOMImplementation: ...
|
||||
def getDOMImplementation(name: str | None = ..., features: str | Iterable[tuple[str, str | None]] = ...) -> DOMImplementation: ...
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
from typing import Any, Iterable, List, Tuple, Type, TypeVar
|
||||
from typing import Any, Iterable, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
StringTypes: Tuple[Type[str]]
|
||||
StringTypes: tuple[type[str]]
|
||||
|
||||
class NodeList(List[_T]):
|
||||
class NodeList(list[_T]):
|
||||
length: int
|
||||
def item(self, index: int) -> _T | None: ...
|
||||
|
||||
class EmptyNodeList(Tuple[Any, ...]):
|
||||
class EmptyNodeList(tuple[Any, ...]):
|
||||
length: int
|
||||
def item(self, index: int) -> None: ...
|
||||
def __add__(self, other: Iterable[_T]) -> NodeList[_T]: ... # type: ignore
|
||||
def __radd__(self, other: Iterable[_T]) -> NodeList[_T]: ...
|
||||
|
||||
def defproperty(klass: Type[Any], name: str, doc: str) -> None: ...
|
||||
def defproperty(klass: type[Any], name: str, doc: str) -> None: ...
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from typing import Callable, Dict, Generator, List, Pattern, Tuple, TypeVar
|
||||
from typing import Callable, Generator, Pattern, TypeVar
|
||||
from xml.etree.ElementTree import Element
|
||||
|
||||
xpath_tokenizer_re: Pattern[str]
|
||||
|
||||
_token = Tuple[str, str]
|
||||
_token = tuple[str, str]
|
||||
_next = Callable[[], _token]
|
||||
_callback = Callable[[_SelectorContext, List[Element]], Generator[Element, None, None]]
|
||||
_callback = Callable[[_SelectorContext, list[Element]], Generator[Element, None, None]]
|
||||
|
||||
def xpath_tokenizer(pattern: str, namespaces: Dict[str, str] | None = ...) -> Generator[_token, None, None]: ...
|
||||
def get_parent_map(context: _SelectorContext) -> Dict[Element, Element]: ...
|
||||
def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = ...) -> Generator[_token, None, None]: ...
|
||||
def get_parent_map(context: _SelectorContext) -> dict[Element, Element]: ...
|
||||
def prepare_child(next: _next, token: _token) -> _callback: ...
|
||||
def prepare_star(next: _next, token: _token) -> _callback: ...
|
||||
def prepare_self(next: _next, token: _token) -> _callback: ...
|
||||
@@ -16,16 +16,16 @@ def prepare_descendant(next: _next, token: _token) -> _callback: ...
|
||||
def prepare_parent(next: _next, token: _token) -> _callback: ...
|
||||
def prepare_predicate(next: _next, token: _token) -> _callback: ...
|
||||
|
||||
ops: Dict[str, Callable[[_next, _token], _callback]]
|
||||
ops: dict[str, Callable[[_next, _token], _callback]]
|
||||
|
||||
class _SelectorContext:
|
||||
parent_map: Dict[Element, Element] | None
|
||||
parent_map: dict[Element, Element] | None
|
||||
root: Element
|
||||
def __init__(self, root: Element) -> None: ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def iterfind(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> Generator[Element, None, None]: ...
|
||||
def find(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> Element | None: ...
|
||||
def findall(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> List[Element]: ...
|
||||
def findtext(elem: Element, path: str, default: _T | None = ..., namespaces: Dict[str, str] | None = ...) -> _T | str: ...
|
||||
def iterfind(elem: Element, path: str, namespaces: dict[str, str] | None = ...) -> Generator[Element, None, None]: ...
|
||||
def find(elem: Element, path: str, namespaces: dict[str, str] | None = ...) -> Element | None: ...
|
||||
def findall(elem: Element, path: str, namespaces: dict[str, str] | None = ...) -> list[Element]: ...
|
||||
def findtext(elem: Element, path: str, default: _T | None = ..., namespaces: dict[str, str] | None = ...) -> _T | str: ...
|
||||
|
||||
@@ -3,17 +3,14 @@ from typing import (
|
||||
IO,
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
ItemsView,
|
||||
Iterable,
|
||||
Iterator,
|
||||
KeysView,
|
||||
List,
|
||||
MutableSequence,
|
||||
Sequence,
|
||||
Text,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
@@ -23,7 +20,7 @@ VERSION: str
|
||||
|
||||
class ParseError(SyntaxError):
|
||||
code: int
|
||||
position: Tuple[int, int]
|
||||
position: tuple[int, int]
|
||||
|
||||
def iselement(element: object) -> bool: ...
|
||||
|
||||
@@ -53,31 +50,31 @@ _file_or_filename = Union[Text, FileDescriptor, IO[Any]]
|
||||
|
||||
class Element(MutableSequence[Element]):
|
||||
tag: _str_result_type
|
||||
attrib: Dict[_str_result_type, _str_result_type]
|
||||
attrib: dict[_str_result_type, _str_result_type]
|
||||
text: _str_result_type | None
|
||||
tail: _str_result_type | None
|
||||
def __init__(
|
||||
self,
|
||||
tag: _str_argument_type | Callable[..., Element],
|
||||
attrib: Dict[_str_argument_type, _str_argument_type] = ...,
|
||||
attrib: dict[_str_argument_type, _str_argument_type] = ...,
|
||||
**extra: _str_argument_type,
|
||||
) -> None: ...
|
||||
def append(self, __subelement: Element) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def extend(self, __elements: Iterable[Element]) -> None: ...
|
||||
def find(
|
||||
self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> Element | None: ...
|
||||
def findall(
|
||||
self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> List[Element]: ...
|
||||
self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> list[Element]: ...
|
||||
@overload
|
||||
def findtext(
|
||||
self, path: _str_argument_type, default: None = ..., namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, default: None = ..., namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> _str_result_type | None: ...
|
||||
@overload
|
||||
def findtext(
|
||||
self, path: _str_argument_type, default: _T, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, default: _T, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> _T | _str_result_type: ...
|
||||
@overload
|
||||
def get(self, key: _str_argument_type, default: None = ...) -> _str_result_type | None: ...
|
||||
@@ -87,11 +84,11 @@ class Element(MutableSequence[Element]):
|
||||
def items(self) -> ItemsView[_str_result_type, _str_result_type]: ...
|
||||
def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ...
|
||||
def iterfind(
|
||||
self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> Generator[Element, None, None]: ...
|
||||
def itertext(self) -> Generator[_str_result_type, None, None]: ...
|
||||
def keys(self) -> KeysView[_str_result_type]: ...
|
||||
def makeelement(self, __tag: _str_argument_type, __attrib: Dict[_str_argument_type, _str_argument_type]) -> Element: ...
|
||||
def makeelement(self, __tag: _str_argument_type, __attrib: dict[_str_argument_type, _str_argument_type]) -> Element: ...
|
||||
def remove(self, __subelement: Element) -> None: ...
|
||||
def set(self, __key: _str_argument_type, __value: _str_argument_type) -> None: ...
|
||||
def __delitem__(self, i: int | slice) -> None: ...
|
||||
@@ -104,13 +101,13 @@ class Element(MutableSequence[Element]):
|
||||
def __setitem__(self, i: int, o: Element) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ...
|
||||
def getchildren(self) -> List[Element]: ...
|
||||
def getiterator(self, tag: _str_argument_type | None = ...) -> List[Element]: ...
|
||||
def getchildren(self) -> list[Element]: ...
|
||||
def getiterator(self, tag: _str_argument_type | None = ...) -> list[Element]: ...
|
||||
|
||||
def SubElement(
|
||||
parent: Element,
|
||||
tag: _str_argument_type,
|
||||
attrib: Dict[_str_argument_type, _str_argument_type] = ...,
|
||||
attrib: dict[_str_argument_type, _str_argument_type] = ...,
|
||||
**extra: _str_argument_type,
|
||||
) -> Element: ...
|
||||
def Comment(text: _str_argument_type | None = ...) -> Element: ...
|
||||
@@ -127,23 +124,23 @@ class ElementTree:
|
||||
def getroot(self) -> Element: ...
|
||||
def parse(self, source: _file_or_filename, parser: XMLParser | None = ...) -> Element: ...
|
||||
def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ...
|
||||
def getiterator(self, tag: _str_argument_type | None = ...) -> List[Element]: ...
|
||||
def getiterator(self, tag: _str_argument_type | None = ...) -> list[Element]: ...
|
||||
def find(
|
||||
self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> Element | None: ...
|
||||
@overload
|
||||
def findtext(
|
||||
self, path: _str_argument_type, default: None = ..., namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, default: None = ..., namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> _str_result_type | None: ...
|
||||
@overload
|
||||
def findtext(
|
||||
self, path: _str_argument_type, default: _T, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, default: _T, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> _T | _str_result_type: ...
|
||||
def findall(
|
||||
self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> List[Element]: ...
|
||||
self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> list[Element]: ...
|
||||
def iterfind(
|
||||
self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ...
|
||||
) -> Generator[Element, None, None]: ...
|
||||
def write(
|
||||
self,
|
||||
@@ -157,14 +154,14 @@ class ElementTree:
|
||||
|
||||
def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ...
|
||||
def tostring(element: Element, encoding: str | None = ..., method: str | None = ...) -> bytes: ...
|
||||
def tostringlist(element: Element, encoding: str | None = ..., method: str | None = ...) -> List[bytes]: ...
|
||||
def tostringlist(element: Element, encoding: str | None = ..., method: str | None = ...) -> list[bytes]: ...
|
||||
def dump(elem: Element) -> None: ...
|
||||
def parse(source: _file_or_filename, parser: XMLParser | None = ...) -> ElementTree: ...
|
||||
def iterparse(
|
||||
source: _file_or_filename, events: Sequence[str] | None = ..., parser: XMLParser | None = ...
|
||||
) -> Iterator[Tuple[str, Any]]: ...
|
||||
) -> Iterator[tuple[str, Any]]: ...
|
||||
def XML(text: _parser_input_type, parser: XMLParser | None = ...) -> Element: ...
|
||||
def XMLID(text: _parser_input_type, parser: XMLParser | None = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ...
|
||||
def XMLID(text: _parser_input_type, parser: XMLParser | None = ...) -> tuple[Element, dict[_str_result_type, Element]]: ...
|
||||
|
||||
# This is aliased to XML in the source.
|
||||
fromstring = XML
|
||||
@@ -180,13 +177,13 @@ def fromstringlist(sequence: Sequence[_parser_input_type], parser: XMLParser | N
|
||||
# TreeBuilder is called by client code (they could pass strs, bytes or whatever);
|
||||
# but we don't want to use a too-broad type, or it would be too hard to write
|
||||
# elementfactories.
|
||||
_ElementFactory = Callable[[Any, Dict[Any, Any]], Element]
|
||||
_ElementFactory = Callable[[Any, dict[Any, Any]], Element]
|
||||
|
||||
class TreeBuilder:
|
||||
def __init__(self, element_factory: _ElementFactory | None = ...) -> None: ...
|
||||
def close(self) -> Element: ...
|
||||
def data(self, __data: _parser_input_type) -> None: ...
|
||||
def start(self, __tag: _parser_input_type, __attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ...
|
||||
def start(self, __tag: _parser_input_type, __attrs: dict[_parser_input_type, _parser_input_type]) -> Element: ...
|
||||
def end(self, __tag: _parser_input_type) -> Element: ...
|
||||
|
||||
class XMLParser:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import IO, Any, List, NoReturn, Text
|
||||
from typing import IO, Any, NoReturn, Text
|
||||
from xml.sax.handler import ContentHandler, ErrorHandler
|
||||
from xml.sax.xmlreader import Locator, XMLReader
|
||||
|
||||
@@ -19,9 +19,9 @@ class SAXNotRecognizedException(SAXException): ...
|
||||
class SAXNotSupportedException(SAXException): ...
|
||||
class SAXReaderNotAvailable(SAXNotSupportedException): ...
|
||||
|
||||
default_parser_list: List[str]
|
||||
default_parser_list: list[str]
|
||||
|
||||
def make_parser(parser_list: List[str] = ...) -> XMLReader: ...
|
||||
def make_parser(parser_list: list[str] = ...) -> XMLReader: ...
|
||||
def parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ...
|
||||
def parseString(string: bytes | Text, handler: ContentHandler, errorHandler: ErrorHandler | None = ...) -> None: ...
|
||||
def _create_parser(parser_name: str) -> XMLReader: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Mapping, Tuple
|
||||
from typing import Mapping
|
||||
|
||||
class XMLReader:
|
||||
def __init__(self) -> None: ...
|
||||
@@ -64,7 +64,7 @@ class AttributesImpl:
|
||||
def values(self): ...
|
||||
|
||||
class AttributesNSImpl(AttributesImpl):
|
||||
def __init__(self, attrs: Mapping[Tuple[str, str], str], qnames: Mapping[Tuple[str, str], str]) -> None: ...
|
||||
def __init__(self, attrs: Mapping[tuple[str, str], str], qnames: Mapping[tuple[str, str], str]) -> None: ...
|
||||
def getValueByQName(self, name): ...
|
||||
def getNameByQName(self, name): ...
|
||||
def getQNameByName(self, name): ...
|
||||
|
||||
Reference in New Issue
Block a user