mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-27 05:12:10 +08:00
Use TypeAlias where possible for type aliases (#7630)
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from typing import Callable, Generator, Pattern, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
from xml.etree.ElementTree import Element
|
||||
|
||||
xpath_tokenizer_re: Pattern[str]
|
||||
|
||||
_token = tuple[str, str]
|
||||
_next = Callable[[], _token]
|
||||
_callback = Callable[[_SelectorContext, list[Element]], Generator[Element, None, None]]
|
||||
_token: TypeAlias = tuple[str, str]
|
||||
_next: TypeAlias = Callable[[], _token]
|
||||
_callback: TypeAlias = 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]: ...
|
||||
|
||||
@@ -14,7 +14,7 @@ from typing import (
|
||||
TypeVar,
|
||||
overload,
|
||||
)
|
||||
from typing_extensions import Literal, SupportsIndex, TypeGuard
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias, TypeGuard
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ = [
|
||||
@@ -101,9 +101,9 @@ else:
|
||||
]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_FileRead = StrOrBytesPath | FileDescriptor | SupportsRead[bytes] | SupportsRead[str]
|
||||
_FileWriteC14N = StrOrBytesPath | FileDescriptor | SupportsWrite[bytes]
|
||||
_FileWrite = _FileWriteC14N | SupportsWrite[str]
|
||||
_FileRead: TypeAlias = StrOrBytesPath | FileDescriptor | SupportsRead[bytes] | SupportsRead[str]
|
||||
_FileWriteC14N: TypeAlias = StrOrBytesPath | FileDescriptor | SupportsWrite[bytes]
|
||||
_FileWrite: TypeAlias = _FileWriteC14N | SupportsWrite[str]
|
||||
|
||||
VERSION: str
|
||||
|
||||
@@ -352,7 +352,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: TypeAlias = Callable[[Any, dict[Any, Any]], Element]
|
||||
|
||||
class TreeBuilder:
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
Reference in New Issue
Block a user