Skip to content

Commit bb38db9

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

File tree

1 file changed

+31
-123
lines changed

1 file changed

+31
-123
lines changed

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 31 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ from typing import ( # noqa: Y027
5454
TypeVar,
5555
overload,
5656
)
57-
from typing_extensions import Literal, LiteralString, SupportsIndex, TypeAlias, TypeGuard, final
57+
from typing_extensions import Literal, SupportsIndex, TypeAlias, TypeGuard, final
5858

5959
if sys.version_info >= (3, 9):
6060
from types import GenericAlias
@@ -401,39 +401,21 @@ class str(Sequence[str]):
401401
def __new__(cls: type[Self], object: object = ...) -> Self: ...
402402
@overload
403403
def __new__(cls: type[Self], object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
404-
@overload
405-
def capitalize(self: LiteralString) -> LiteralString: ...
406-
@overload
407-
def capitalize(self) -> str: ... # type: ignore[misc]
408-
@overload
409-
def casefold(self: LiteralString) -> LiteralString: ...
410-
@overload
411-
def casefold(self) -> str: ... # type: ignore[misc]
412-
@overload
413-
def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
414-
@overload
415-
def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
404+
def capitalize(self) -> str: ...
405+
def casefold(self) -> str: ...
406+
def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
416407
def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
417408
def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
418409
def endswith(
419410
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
420411
) -> bool: ...
421412
if sys.version_info >= (3, 8):
422-
@overload
423-
def expandtabs(self: LiteralString, tabsize: SupportsIndex = ...) -> LiteralString: ...
424-
@overload
425-
def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... # type: ignore[misc]
413+
def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ...
426414
else:
427-
@overload
428-
def expandtabs(self: LiteralString, tabsize: int = ...) -> LiteralString: ...
429-
@overload
430-
def expandtabs(self, tabsize: int = ...) -> str: ... # type: ignore[misc]
415+
def expandtabs(self, tabsize: int = ...) -> str: ...
431416

432417
def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
433-
@overload
434-
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
435-
@overload
436-
def format(self, *args: object, **kwargs: object) -> str: ... # type: ignore[misc]
418+
def format(self, *args: object, **kwargs: object) -> str: ...
437419
def format_map(self, map: _FormatMapMapping) -> str: ...
438420
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
439421
def isalnum(self) -> bool: ...
@@ -450,129 +432,55 @@ class str(Sequence[str]):
450432
def isspace(self) -> bool: ...
451433
def istitle(self) -> bool: ...
452434
def isupper(self) -> bool: ...
453-
@overload
454-
def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ...
455-
@overload
456-
def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc]
457-
@overload
458-
def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
459-
@overload
460-
def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
461-
@overload
462-
def lower(self: LiteralString) -> LiteralString: ...
463-
@overload
464-
def lower(self) -> str: ... # type: ignore[misc]
465-
@overload
466-
def lstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
467-
@overload
468-
def lstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
469-
@overload
470-
def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
471-
@overload
472-
def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
473-
@overload
474-
def replace(
475-
self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = ...
476-
) -> LiteralString: ...
477-
@overload
478-
def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ... # type: ignore[misc]
435+
def join(self, __iterable: Iterable[str]) -> str: ...
436+
def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
437+
def lower(self) -> str: ...
438+
def lstrip(self, __chars: str | None = ...) -> str: ...
439+
def partition(self, __sep: str) -> tuple[str, str, str]: ...
440+
def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ...
479441
if sys.version_info >= (3, 9):
480-
@overload
481-
def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ...
482-
@overload
483-
def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc]
484-
@overload
485-
def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ...
486-
@overload
487-
def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc]
442+
def removeprefix(self, __prefix: str) -> str: ...
443+
def removesuffix(self, __suffix: str) -> str: ...
488444

489445
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
490446
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
491-
@overload
492-
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
493-
@overload
494-
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
495-
@overload
496-
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
497-
@overload
498-
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
499-
@overload
500-
def rsplit(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
501-
@overload
502-
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
503-
@overload
504-
def rstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
505-
@overload
506-
def rstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
507-
@overload
508-
def split(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
509-
@overload
510-
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
511-
@overload
512-
def splitlines(self: LiteralString, keepends: bool = ...) -> list[LiteralString]: ...
513-
@overload
514-
def splitlines(self, keepends: bool = ...) -> list[str]: ... # type: ignore[misc]
447+
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
448+
def rpartition(self, __sep: str) -> tuple[str, str, str]: ...
449+
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
450+
def rstrip(self, __chars: str | None = ...) -> str: ...
451+
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
452+
def splitlines(self, keepends: bool = ...) -> list[str]: ...
515453
def startswith(
516454
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
517455
) -> bool: ...
518-
@overload
519-
def strip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
520-
@overload
521-
def strip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
522-
@overload
523-
def swapcase(self: LiteralString) -> LiteralString: ...
524-
@overload
525-
def swapcase(self) -> str: ... # type: ignore[misc]
526-
@overload
527-
def title(self: LiteralString) -> LiteralString: ...
528-
@overload
529-
def title(self) -> str: ... # type: ignore[misc]
456+
def strip(self, __chars: str | None = ...) -> str: ...
457+
def swapcase(self) -> str: ...
458+
def title(self) -> str: ...
530459
def translate(self, __table: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ...
531-
@overload
532-
def upper(self: LiteralString) -> LiteralString: ...
533-
@overload
534-
def upper(self) -> str: ... # type: ignore[misc]
535-
@overload
536-
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
537-
@overload
538-
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
460+
def upper(self) -> str: ...
461+
def zfill(self, __width: SupportsIndex) -> str: ...
539462
@staticmethod
540463
@overload
541464
def maketrans(__x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ...
542465
@staticmethod
543466
@overload
544467
def maketrans(__x: str, __y: str, __z: str | None = ...) -> dict[int, int | None]: ...
545-
@overload
546-
def __add__(self: LiteralString, __s: LiteralString) -> LiteralString: ...
547-
@overload
548-
def __add__(self, __s: str) -> str: ... # type: ignore[misc]
468+
def __add__(self, __s: str) -> str: ...
549469
# Incompatible with Sequence.__contains__
550470
def __contains__(self, __o: str) -> bool: ... # type: ignore[override]
551471
def __eq__(self, __x: object) -> bool: ...
552472
def __ge__(self, __x: str) -> bool: ...
553473
def __getitem__(self, __i: SupportsIndex | slice) -> str: ...
554474
def __gt__(self, __x: str) -> bool: ...
555475
def __hash__(self) -> int: ...
556-
@overload
557-
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
558-
@overload
559-
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
476+
def __iter__(self) -> Iterator[str]: ...
560477
def __le__(self, __x: str) -> bool: ...
561478
def __len__(self) -> int: ...
562479
def __lt__(self, __x: str) -> bool: ...
563-
@overload
564-
def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
565-
@overload
566-
def __mod__(self, __x: Any) -> str: ... # type: ignore[misc]
567-
@overload
568-
def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
569-
@overload
570-
def __mul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
480+
def __mod__(self, __x: Any) -> str: ...
481+
def __mul__(self, __n: SupportsIndex) -> str: ...
571482
def __ne__(self, __x: object) -> bool: ...
572-
@overload
573-
def __rmul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
574-
@overload
575-
def __rmul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
483+
def __rmul__(self, __n: SupportsIndex) -> str: ...
576484
def __getnewargs__(self) -> tuple[str]: ...
577485

578486
class bytes(ByteString):

0 commit comments

Comments
 (0)