Skip to content

Commit 6bc2771

Browse files
ilevkivskyiIvan Levkivskyi
authored andcommitted
Remove use of LiteralString in builtins (#13093)
Fixes #13091 Co-authored-by: Ivan Levkivskyi <[email protected]>
1 parent da8819c commit 6bc2771

File tree

1 file changed

+32
-123
lines changed

1 file changed

+32
-123
lines changed

mypy/typeshed/stdlib/builtins.pyi

+32-123
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ from typing import ( # noqa: Y027
5555
overload,
5656
type_check_only,
5757
)
58-
from typing_extensions import Literal, LiteralString, SupportsIndex, TypeAlias, TypeGuard, final
58+
from typing_extensions import Literal, SupportsIndex, TypeAlias, TypeGuard, final
5959

6060
if sys.version_info >= (3, 9):
6161
from types import GenericAlias
@@ -413,39 +413,21 @@ class str(Sequence[str]):
413413
def __new__(cls: type[Self], object: object = ...) -> Self: ...
414414
@overload
415415
def __new__(cls: type[Self], object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
416-
@overload
417-
def capitalize(self: LiteralString) -> LiteralString: ...
418-
@overload
419-
def capitalize(self) -> str: ... # type: ignore[misc]
420-
@overload
421-
def casefold(self: LiteralString) -> LiteralString: ...
422-
@overload
423-
def casefold(self) -> str: ... # type: ignore[misc]
424-
@overload
425-
def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
426-
@overload
427-
def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
416+
def capitalize(self) -> str: ...
417+
def casefold(self) -> str: ...
418+
def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
428419
def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
429420
def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
430421
def endswith(
431422
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
432423
) -> bool: ...
433424
if sys.version_info >= (3, 8):
434-
@overload
435-
def expandtabs(self: LiteralString, tabsize: SupportsIndex = ...) -> LiteralString: ...
436-
@overload
437-
def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... # type: ignore[misc]
425+
def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ...
438426
else:
439-
@overload
440-
def expandtabs(self: LiteralString, tabsize: int = ...) -> LiteralString: ...
441-
@overload
442-
def expandtabs(self, tabsize: int = ...) -> str: ... # type: ignore[misc]
427+
def expandtabs(self, tabsize: int = ...) -> str: ...
443428

444429
def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
445-
@overload
446-
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
447-
@overload
448-
def format(self, *args: object, **kwargs: object) -> str: ... # type: ignore[misc]
430+
def format(self, *args: object, **kwargs: object) -> str: ...
449431
def format_map(self, map: _FormatMapMapping) -> str: ...
450432
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
451433
def isalnum(self) -> bool: ...
@@ -460,128 +442,55 @@ class str(Sequence[str]):
460442
def isspace(self) -> bool: ...
461443
def istitle(self) -> bool: ...
462444
def isupper(self) -> bool: ...
463-
@overload
464-
def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ...
465-
@overload
466-
def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc]
467-
@overload
468-
def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
469-
@overload
470-
def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
471-
@overload
472-
def lower(self: LiteralString) -> LiteralString: ...
473-
@overload
474-
def lower(self) -> str: ... # type: ignore[misc]
475-
@overload
476-
def lstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
477-
@overload
478-
def lstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
479-
@overload
480-
def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
481-
@overload
482-
def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
483-
@overload
484-
def replace(
485-
self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = ...
486-
) -> LiteralString: ...
487-
@overload
488-
def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ... # type: ignore[misc]
445+
def join(self, __iterable: Iterable[str]) -> str: ...
446+
def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
447+
def lower(self) -> str: ...
448+
def lstrip(self, __chars: str | None = ...) -> str: ...
449+
def partition(self, __sep: str) -> tuple[str, str, str]: ...
450+
def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ...
489451
if sys.version_info >= (3, 9):
490-
@overload
491-
def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ...
492-
@overload
493-
def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc]
494-
@overload
495-
def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ...
496-
@overload
497-
def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc]
452+
def removeprefix(self, __prefix: str) -> str: ...
453+
def removesuffix(self, __suffix: str) -> str: ...
498454

499455
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
500456
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
501-
@overload
502-
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
503-
@overload
504-
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
505-
@overload
506-
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
507-
@overload
508-
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
509-
@overload
510-
def rsplit(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
511-
@overload
512-
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
513-
@overload
514-
def rstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
515-
@overload
516-
def rstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
517-
@overload
518-
def split(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
519-
@overload
520-
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
521-
@overload
522-
def splitlines(self: LiteralString, keepends: bool = ...) -> list[LiteralString]: ...
523-
@overload
524-
def splitlines(self, keepends: bool = ...) -> list[str]: ... # type: ignore[misc]
457+
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
458+
def rpartition(self, __sep: str) -> tuple[str, str, str]: ...
459+
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
460+
def rstrip(self, __chars: str | None = ...) -> str: ...
461+
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
462+
def splitlines(self, keepends: bool = ...) -> list[str]: ...
525463
def startswith(
526464
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
527465
) -> bool: ...
528-
@overload
529-
def strip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
530-
@overload
531-
def strip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
532-
@overload
533-
def swapcase(self: LiteralString) -> LiteralString: ...
534-
@overload
535-
def swapcase(self) -> str: ... # type: ignore[misc]
536-
@overload
537-
def title(self: LiteralString) -> LiteralString: ...
538-
@overload
539-
def title(self) -> str: ... # type: ignore[misc]
466+
def strip(self, __chars: str | None = ...) -> str: ...
467+
def swapcase(self) -> str: ...
468+
def title(self) -> str: ...
540469
def translate(self, __table: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ...
541-
@overload
542-
def upper(self: LiteralString) -> LiteralString: ...
543-
@overload
544-
def upper(self) -> str: ... # type: ignore[misc]
545-
@overload
546-
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
547-
@overload
548-
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
470+
def upper(self) -> str: ...
471+
def zfill(self, __width: SupportsIndex) -> str: ...
549472
@staticmethod
550473
@overload
551474
def maketrans(__x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ...
552475
@staticmethod
553476
@overload
554477
def maketrans(__x: str, __y: str, __z: str | None = ...) -> dict[int, int | None]: ...
555-
@overload
556-
def __add__(self: LiteralString, __s: LiteralString) -> LiteralString: ...
557-
@overload
558-
def __add__(self, __s: str) -> str: ... # type: ignore[misc]
478+
def __add__(self, __s: str) -> str: ...
559479
# Incompatible with Sequence.__contains__
560480
def __contains__(self, __o: str) -> bool: ... # type: ignore[override]
561481
def __eq__(self, __x: object) -> bool: ...
562482
def __ge__(self, __x: str) -> bool: ...
563483
def __getitem__(self, __i: SupportsIndex | slice) -> str: ...
564484
def __gt__(self, __x: str) -> bool: ...
565-
@overload
566-
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
567-
@overload
568-
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
485+
def __hash__(self) -> int: ...
486+
def __iter__(self) -> Iterator[str]: ...
569487
def __le__(self, __x: str) -> bool: ...
570488
def __len__(self) -> int: ...
571489
def __lt__(self, __x: str) -> bool: ...
572-
@overload
573-
def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
574-
@overload
575-
def __mod__(self, __x: Any) -> str: ... # type: ignore[misc]
576-
@overload
577-
def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
578-
@overload
579-
def __mul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
490+
def __mod__(self, __x: Any) -> str: ...
491+
def __mul__(self, __n: SupportsIndex) -> str: ...
580492
def __ne__(self, __x: object) -> bool: ...
581-
@overload
582-
def __rmul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
583-
@overload
584-
def __rmul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
493+
def __rmul__(self, __n: SupportsIndex) -> str: ...
585494
def __getnewargs__(self) -> tuple[str]: ...
586495

587496
class bytes(ByteString):

0 commit comments

Comments
 (0)