mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-10-09 06:45:51 +08:00
Refine str.maketrans and str.translate (#1613)
str.translate requires a Mapping or Sequence (in essence, anything with __getitem__), not a Dict. str.maketrans in the one-argument form only converts character string keys to their unicode ordinal, leaving any of the values untouched. This mapping may use both integers or strings as keys at the same time. str.maketrans in the multi-argument form returns a dict with any of the values str, int or None, as recognized by str.translate.
This commit is contained in:
1 parent
c7bc0bdb00
commit
f933b9384c
3 files changed
+7
-7
No files matched your search
@@ -159,10 +159,10 @@ class UserString(Sequence[str]):
|
||||
if sys.version_info >= (3, 5):
|
||||
@staticmethod
|
||||
@overload
|
||||
def maketrans(x: Union[Dict[int, Any], Dict[str, Any]]) -> Dict[int, Any]: ...
|
||||
def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ...
|
||||
@staticmethod
|
||||
@overload
|
||||
def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Any]: ...
|
||||
def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ...
|
||||
def partition(self, sep: str) -> Tuple[str, str, str]: ...
|
||||
def replace(self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ...) -> _UserStringT: ...
|
||||
def rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
|
||||
|
||||
Reference in new issue
Block a user