Use PEP 585 syntax wherever possible (#6717)

This commit is contained in:
Alex Waygood
2021-12-28 10:31:43 +00:00
committed by GitHub
parent e6cb341d94
commit 8d5d2520ac
237 changed files with 966 additions and 1069 deletions

View File

@@ -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]: ...

View File

@@ -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):