mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
Use PEP 585 syntax wherever possible (#6717)
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
from typing import Any, Iterable, List, Tuple, Type, TypeVar
|
||||
from typing import Any, Iterable, Type, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
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[override]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from typing import IO, Any, Sequence, Tuple, Union
|
||||
from typing import IO, Any, Sequence, Union
|
||||
from typing_extensions import Literal
|
||||
from xml.dom.minidom import Document, DOMImplementation, Element, Text
|
||||
from xml.sax.handler import ContentHandler
|
||||
@@ -17,7 +17,7 @@ CHARACTERS: Literal["CHARACTERS"]
|
||||
_DocumentFactory = Union[DOMImplementation, None]
|
||||
_Node = Union[Document, Element, Text]
|
||||
|
||||
_Event = Tuple[
|
||||
_Event = tuple[
|
||||
Literal[
|
||||
Literal["START_ELEMENT"],
|
||||
Literal["END_ELEMENT"],
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from typing import Callable, 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]: ...
|
||||
|
||||
@@ -4,7 +4,6 @@ from typing import (
|
||||
IO,
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
ItemsView,
|
||||
Iterable,
|
||||
@@ -257,7 +256,7 @@ def fromstringlist(sequence: Sequence[str | bytes], parser: XMLParser | None = .
|
||||
# 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:
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
Reference in New Issue
Block a user