Use PEP 570 syntax in third party stubs (#11554)

This commit is contained in:
Shantanu
2024-03-10 06:11:43 -07:00
committed by GitHub
parent f94bbfbcc4
commit 88fa182253
97 changed files with 625 additions and 632 deletions
+1 -1
View File
@@ -27,4 +27,4 @@ _VisibilityType: TypeAlias = Literal["visible", "hidden", "veryHidden"] # noqa:
_ZipFileFileProtocol: TypeAlias = StrPath | IO[bytes] | SupportsRead[bytes] # noqa: Y047
class _Decodable(Protocol): # noqa: Y046
def decode(self, __encoding: str) -> str: ...
def decode(self, encoding: str, /) -> str: ...
+1 -1
View File
@@ -15,7 +15,7 @@ class TextBlock(Strict):
class CellRichText(list[str | TextBlock]):
@overload
def __init__(self, __args: list[str] | list[TextBlock] | list[str | TextBlock] | tuple[str | TextBlock, ...]) -> None: ...
def __init__(self, args: list[str] | list[TextBlock] | list[str | TextBlock] | tuple[str | TextBlock, ...], /) -> None: ...
@overload
def __init__(self, *args: str | TextBlock) -> None: ...
@classmethod
+4 -4
View File
@@ -2,14 +2,14 @@ from typing import Any, overload
class Singleton(type):
@overload
def __init__(self, __o: object) -> None: ...
def __init__(self, o: object, /) -> None: ...
@overload
def __init__(self, __name: str, __bases: tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ...
def __init__(self, name: str, bases: tuple[type, ...], dict: dict[str, Any], /, **kwds: Any) -> None: ...
def __call__(self, *args: Any, **kwds: Any) -> Any: ...
class Cached(type):
@overload
def __init__(self, __o: object) -> None: ...
def __init__(self, o: object, /) -> None: ...
@overload
def __init__(self, __name: str, __bases: tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ...
def __init__(self, name: str, bases: tuple[type, ...], dict: dict[str, Any], /, **kwds: Any) -> None: ...
def __call__(self, *args: Any) -> Any: ...
@@ -5,7 +5,7 @@ from typing_extensions import TypeAlias
# WorksheetWriter.read has an explicit BytesIO branch. Let's make sure this protocol is viable for BytesIO too.
class _SupportsCloseAndWrite(Protocol):
def write(self, __buffer: ReadableBuffer) -> Unused: ...
def write(self, buffer: ReadableBuffer, /) -> Unused: ...
def close(self) -> Unused: ...
# et_xmlfile.xmlfile accepts a str | _SupportsCloseAndWrite
@@ -21,7 +21,7 @@ class _HasTag(Protocol):
tag: str
class _HasGet(Protocol[_T_co]):
def get(self, __value: str) -> _T_co | None: ...
def get(self, value: str, /) -> _T_co | None: ...
class _HasText(Protocol):
text: str
@@ -34,7 +34,7 @@ class _HasTagAndText(_HasTag, _HasText, Protocol): ... # noqa: Y046
class _HasTagAndTextAndAttrib(_HasTag, _HasText, _HasAttrib, Protocol): ... # noqa: Y046
class _SupportsFindChartLines(Protocol):
def find(self, __path: str) -> ChartLines | None: ...
def find(self, path: str, /) -> ChartLines | None: ...
class _SupportsFindAndIterAndAttribAndText( # noqa: Y046
_SupportsFindChartLines, Iterable[Incomplete], _HasAttrib, _HasText, Protocol
@@ -46,8 +46,8 @@ class _SupportsIterAndAttribAndTextAndGet( # noqa: Y046
): ...
class _ParentElement(Protocol[_T]):
def makeelement(self, __tag: str, __attrib: dict[str, str]) -> _T: ...
def append(self, __element: _T) -> object: ...
def makeelement(self, tag: str, attrib: dict[str, str], /) -> _T: ...
def append(self, element: _T, /) -> object: ...
# from lxml.etree import _Element
_lxml_Element: TypeAlias = Element # noqa: Y042