Accept anything with __getitem__ in str.translate (#8629)

translate table protocol
This commit is contained in:
GrozniyToaster
2022-08-26 20:24:21 +03:00
committed by GitHub
parent 0259068ad6
commit b6b8894964

View File

@@ -406,6 +406,9 @@ class complex:
class _FormatMapMapping(Protocol):
def __getitem__(self, __key: str) -> Any: ...
class _TranslateTable(Protocol):
def __getitem__(self, __key: int) -> str | int | None: ...
class str(Sequence[str]):
@overload
def __new__(cls: type[Self], object: object = ...) -> Self: ...
@@ -535,7 +538,7 @@ class str(Sequence[str]):
def title(self: LiteralString) -> LiteralString: ...
@overload
def title(self) -> str: ... # type: ignore[misc]
def translate(self, __table: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ...
def translate(self, __table: _TranslateTable) -> str: ...
@overload
def upper(self: LiteralString) -> LiteralString: ...
@overload