Skip to content

Commit ce891e3

Browse files
ilevkivskyiIvan Levkivskyi
and
Ivan Levkivskyi
authored
Remove use of LiteralString in builtins (#13093)
Fixes #13091 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
1 parent 7a6ecd3 commit ce891e3

File tree

1 file changed

+31
-123
lines changed

1 file changed

+31
-123
lines changed

mypy/typeshed/stdlib/builtins.pyi

+31-123
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
@@ -400,39 +400,21 @@ class str(Sequence[str]):
400400
def __new__(cls: type[Self], object: object = ...) -> Self: ...
401401
@overload
402402
def __new__(cls: type[Self], object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
403-
@overload
404-
def capitalize(self: LiteralString) -> LiteralString: ...
405-
@overload
406-
def capitalize(self) -> str: ... # type: ignore[misc]
407-
@overload
408-
def casefold(self: LiteralString) -> LiteralString: ...
409-
@overload
410-
def casefold(self) -> str: ... # type: ignore[misc]
411-
@overload
412-
def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
413-
@overload
414-
def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
403+
def capitalize(self) -> str: ...
404+
def casefold(self) -> str: ...
405+
def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
415406
def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
416407
def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
417408
def endswith(
418409
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
419410
) -> bool: ...
420411
if sys.version_info >= (3, 8):
421-
@overload
422-
def expandtabs(self: LiteralString, tabsize: SupportsIndex = ...) -> LiteralString: ...
423-
@overload
424-
def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... # type: ignore[misc]
412+
def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ...
425413
else:
426-
@overload
427-
def expandtabs(self: LiteralString, tabsize: int = ...) -> LiteralString: ...
428-
@overload
429-
def expandtabs(self, tabsize: int = ...) -> str: ... # type: ignore[misc]
414+
def expandtabs(self, tabsize: int = ...) -> str: ...
430415

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

488444
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
489445
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
490-
@overload
491-
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
492-
@overload
493-
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
494-
@overload
495-
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
496-
@overload
497-
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
498-
@overload
499-
def rsplit(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
500-
@overload
501-
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
502-
@overload
503-
def rstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
504-
@overload
505-
def rstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
506-
@overload
507-
def split(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
508-
@overload
509-
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
510-
@overload
511-
def splitlines(self: LiteralString, keepends: bool = ...) -> list[LiteralString]: ...
512-
@overload
513-
def splitlines(self, keepends: bool = ...) -> list[str]: ... # type: ignore[misc]
446+
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
447+
def rpartition(self, __sep: str) -> tuple[str, str, str]: ...
448+
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
449+
def rstrip(self, __chars: str | None = ...) -> str: ...
450+
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
451+
def splitlines(self, keepends: bool = ...) -> list[str]: ...
514452
def startswith(
515453
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
516454
) -> bool: ...
517-
@overload
518-
def strip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
519-
@overload
520-
def strip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
521-
@overload
522-
def swapcase(self: LiteralString) -> LiteralString: ...
523-
@overload
524-
def swapcase(self) -> str: ... # type: ignore[misc]
525-
@overload
526-
def title(self: LiteralString) -> LiteralString: ...
527-
@overload
528-
def title(self) -> str: ... # type: ignore[misc]
455+
def strip(self, __chars: str | None = ...) -> str: ...
456+
def swapcase(self) -> str: ...
457+
def title(self) -> str: ...
529458
def translate(self, __table: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ...
530-
@overload
531-
def upper(self: LiteralString) -> LiteralString: ...
532-
@overload
533-
def upper(self) -> str: ... # type: ignore[misc]
534-
@overload
535-
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
536-
@overload
537-
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
459+
def upper(self) -> str: ...
460+
def zfill(self, __width: SupportsIndex) -> str: ...
538461
@staticmethod
539462
@overload
540463
def maketrans(__x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ...
541464
@staticmethod
542465
@overload
543466
def maketrans(__x: str, __y: str, __z: str | None = ...) -> dict[int, int | None]: ...
544-
@overload
545-
def __add__(self: LiteralString, __s: LiteralString) -> LiteralString: ...
546-
@overload
547-
def __add__(self, __s: str) -> str: ... # type: ignore[misc]
467+
def __add__(self, __s: str) -> str: ...
548468
# Incompatible with Sequence.__contains__
549469
def __contains__(self, __o: str) -> bool: ... # type: ignore[override]
550470
def __eq__(self, __x: object) -> bool: ...
551471
def __ge__(self, __x: str) -> bool: ...
552472
def __getitem__(self, __i: SupportsIndex | slice) -> str: ...
553473
def __gt__(self, __x: str) -> bool: ...
554474
def __hash__(self) -> int: ...
555-
@overload
556-
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
557-
@overload
558-
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
475+
def __iter__(self) -> Iterator[str]: ...
559476
def __le__(self, __x: str) -> bool: ...
560477
def __len__(self) -> int: ...
561478
def __lt__(self, __x: str) -> bool: ...
562-
@overload
563-
def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
564-
@overload
565-
def __mod__(self, __x: Any) -> str: ... # type: ignore[misc]
566-
@overload
567-
def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
568-
@overload
569-
def __mul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
479+
def __mod__(self, __x: Any) -> str: ...
480+
def __mul__(self, __n: SupportsIndex) -> str: ...
570481
def __ne__(self, __x: object) -> bool: ...
571-
@overload
572-
def __rmul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
573-
@overload
574-
def __rmul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
482+
def __rmul__(self, __n: SupportsIndex) -> str: ...
575483
def __getnewargs__(self) -> tuple[str]: ...
576484

577485
class bytes(ByteString):

0 commit comments

Comments
 (0)