Use TypeGuard in ElementTree.pyi (#7059)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Nikita Sobolev
2022-01-28 12:33:45 +03:00
committed by GitHub
parent 4390b88986
commit 92d135a37c

View File

@@ -16,7 +16,7 @@ from typing import (
Union,
overload,
)
from typing_extensions import Literal, SupportsIndex
from typing_extensions import Literal, SupportsIndex, TypeGuard
_T = TypeVar("_T")
_File = Union[StrOrBytesPath, FileDescriptor, IO[Any]]
@@ -27,7 +27,8 @@ class ParseError(SyntaxError):
code: int
position: tuple[int, int]
def iselement(element: object) -> bool: ...
# In reality it works based on `.tag` attribute duck typing.
def iselement(element: object) -> TypeGuard[Element]: ...
if sys.version_info >= (3, 8):
@overload