Skip to content

Commit b8ec4da

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

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: ...
@@ -448,129 +430,55 @@ class str(Sequence[str]):
448430
def isspace(self) -> bool: ...
449431
def istitle(self) -> bool: ...
450432
def isupper(self) -> bool: ...
451-
@overload
452-
def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ...
453-
@overload
454-
def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc]
455-
@overload
456-
def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
457-
@overload
458-
def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
459-
@overload
460-
def lower(self: LiteralString) -> LiteralString: ...
461-
@overload
462-
def lower(self) -> str: ... # type: ignore[misc]
463-
@overload
464-
def lstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
465-
@overload
466-
def lstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
467-
@overload
468-
def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
469-
@overload
470-
def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
471-
@overload
472-
def replace(
473-
self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = ...
474-
) -> LiteralString: ...
475-
@overload
476-
def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ... # type: ignore[misc]
433+
def join(self, __iterable: Iterable[str]) -> str: ...
434+
def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
435+
def lower(self) -> str: ...
436+
def lstrip(self, __chars: str | None = ...) -> str: ...
437+
def partition(self, __sep: str) -> tuple[str, str, str]: ...
438+
def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ...
477439
if sys.version_info >= (3, 9):
478-
@overload
479-
def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ...
480-
@overload
481-
def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc]
482-
@overload
483-
def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ...
484-
@overload
485-
def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc]
440+
def removeprefix(self, __prefix: str) -> str: ...
441+
def removesuffix(self, __suffix: str) -> str: ...
486442

487443
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
488444
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
489-
@overload
490-
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
491-
@overload
492-
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
493-
@overload
494-
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
495-
@overload
496-
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
497-
@overload
498-
def rsplit(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
499-
@overload
500-
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
501-
@overload
502-
def rstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
503-
@overload
504-
def rstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
505-
@overload
506-
def split(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
507-
@overload
508-
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
509-
@overload
510-
def splitlines(self: LiteralString, keepends: bool = ...) -> list[LiteralString]: ...
511-
@overload
512-
def splitlines(self, keepends: bool = ...) -> list[str]: ... # type: ignore[misc]
445+
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ...
446+
def rpartition(self, __sep: str) -> tuple[str, str, str]: ...
447+
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
448+
def rstrip(self, __chars: str | None = ...) -> str: ...
449+
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ...
450+
def splitlines(self, keepends: bool = ...) -> list[str]: ...
513451
def startswith(
514452
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
515453
) -> bool: ...
516-
@overload
517-
def strip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
518-
@overload
519-
def strip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
520-
@overload
521-
def swapcase(self: LiteralString) -> LiteralString: ...
522-
@overload
523-
def swapcase(self) -> str: ... # type: ignore[misc]
524-
@overload
525-
def title(self: LiteralString) -> LiteralString: ...
526-
@overload
527-
def title(self) -> str: ... # type: ignore[misc]
454+
def strip(self, __chars: str | None = ...) -> str: ...
455+
def swapcase(self) -> str: ...
456+
def title(self) -> str: ...
528457
def translate(self, __table: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ...
529-
@overload
530-
def upper(self: LiteralString) -> LiteralString: ...
531-
@overload
532-
def upper(self) -> str: ... # type: ignore[misc]
533-
@overload
534-
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
535-
@overload
536-
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
458+
def upper(self) -> str: ...
459+
def zfill(self, __width: SupportsIndex) -> str: ...
537460
@staticmethod
538461
@overload
539462
def maketrans(__x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ...
540463
@staticmethod
541464
@overload
542465
def maketrans(__x: str, __y: str, __z: str | None = ...) -> dict[int, int | None]: ...
543-
@overload
544-
def __add__(self: LiteralString, __s: LiteralString) -> LiteralString: ...
545-
@overload
546-
def __add__(self, __s: str) -> str: ... # type: ignore[misc]
466+
def __add__(self, __s: str) -> str: ...
547467
# Incompatible with Sequence.__contains__
548468
def __contains__(self, __o: str) -> bool: ... # type: ignore[override]
549469
def __eq__(self, __x: object) -> bool: ...
550470
def __ge__(self, __x: str) -> bool: ...
551471
def __getitem__(self, __i: SupportsIndex | slice) -> str: ...
552472
def __gt__(self, __x: str) -> bool: ...
553473
def __hash__(self) -> int: ...
554-
@overload
555-
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
556-
@overload
557-
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
474+
def __iter__(self) -> Iterator[str]: ...
558475
def __le__(self, __x: str) -> bool: ...
559476
def __len__(self) -> int: ...
560477
def __lt__(self, __x: str) -> bool: ...
561-
@overload
562-
def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
563-
@overload
564-
def __mod__(self, __x: Any) -> str: ... # type: ignore[misc]
565-
@overload
566-
def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
567-
@overload
568-
def __mul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
478+
def __mod__(self, __x: Any) -> str: ...
479+
def __mul__(self, __n: SupportsIndex) -> str: ...
569480
def __ne__(self, __x: object) -> bool: ...
570-
@overload
571-
def __rmul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
572-
@overload
573-
def __rmul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
481+
def __rmul__(self, __n: SupportsIndex) -> str: ...
574482
def __getnewargs__(self) -> tuple[str]: ...
575483

576484
class bytes(ByteString):

0 commit comments

Comments
 (0)