Skip to content

Commit 03885d9

Browse files
hauntsaninjaAlexWaygood
authored andcommitted
Remove use of LiteralString in builtins (python#13743)
1 parent a995642 commit 03885d9

File tree

1 file changed

+1
-93
lines changed

1 file changed

+1
-93
lines changed

mypy/typeshed/stdlib/builtins.pyi

+1-93
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ from typing import ( # noqa: Y022
5454
overload,
5555
type_check_only,
5656
)
57-
from typing_extensions import Literal, LiteralString, Self, SupportsIndex, TypeAlias, TypeGuard, final
57+
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias, TypeGuard, final
5858

5959
if sys.version_info >= (3, 9):
6060
from types import GenericAlias
@@ -415,38 +415,20 @@ class str(Sequence[str]):
415415
def __new__(cls, object: object = ...) -> Self: ...
416416
@overload
417417
def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
418-
@overload
419-
def capitalize(self: LiteralString) -> LiteralString: ...
420-
@overload
421418
def capitalize(self) -> str: ... # type: ignore[misc]
422-
@overload
423-
def casefold(self: LiteralString) -> LiteralString: ...
424-
@overload
425419
def casefold(self) -> str: ... # type: ignore[misc]
426-
@overload
427-
def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
428-
@overload
429420
def center(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
430421
def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
431422
def encode(self, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
432423
def endswith(
433424
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
434425
) -> bool: ...
435426
if sys.version_info >= (3, 8):
436-
@overload
437-
def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...
438-
@overload
439427
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
440428
else:
441-
@overload
442-
def expandtabs(self: LiteralString, tabsize: int = 8) -> LiteralString: ...
443-
@overload
444429
def expandtabs(self, tabsize: int = 8) -> str: ... # type: ignore[misc]
445430

446431
def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
447-
@overload
448-
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
449-
@overload
450432
def format(self, *args: object, **kwargs: object) -> str: ...
451433
def format_map(self, map: _FormatMapMapping) -> str: ...
452434
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
@@ -462,91 +444,32 @@ class str(Sequence[str]):
462444
def isspace(self) -> bool: ...
463445
def istitle(self) -> bool: ...
464446
def isupper(self) -> bool: ...
465-
@overload
466-
def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ...
467-
@overload
468447
def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc]
469-
@overload
470-
def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
471-
@overload
472448
def ljust(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
473-
@overload
474-
def lower(self: LiteralString) -> LiteralString: ...
475-
@overload
476449
def lower(self) -> str: ... # type: ignore[misc]
477-
@overload
478-
def lstrip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
479-
@overload
480450
def lstrip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
481-
@overload
482-
def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
483-
@overload
484451
def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
485-
@overload
486-
def replace(
487-
self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = -1
488-
) -> LiteralString: ...
489-
@overload
490452
def replace(self, __old: str, __new: str, __count: SupportsIndex = -1) -> str: ... # type: ignore[misc]
491453
if sys.version_info >= (3, 9):
492-
@overload
493-
def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ...
494-
@overload
495454
def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc]
496-
@overload
497-
def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ...
498-
@overload
499455
def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc]
500456

501457
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
502458
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
503-
@overload
504-
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
505-
@overload
506459
def rjust(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
507-
@overload
508-
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
509-
@overload
510460
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
511-
@overload
512-
def rsplit(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
513-
@overload
514461
def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
515-
@overload
516-
def rstrip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
517-
@overload
518462
def rstrip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
519-
@overload
520-
def split(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
521-
@overload
522463
def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
523-
@overload
524-
def splitlines(self: LiteralString, keepends: bool = False) -> list[LiteralString]: ...
525-
@overload
526464
def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]
527465
def startswith(
528466
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
529467
) -> bool: ...
530-
@overload
531-
def strip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
532-
@overload
533468
def strip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
534-
@overload
535-
def swapcase(self: LiteralString) -> LiteralString: ...
536-
@overload
537469
def swapcase(self) -> str: ... # type: ignore[misc]
538-
@overload
539-
def title(self: LiteralString) -> LiteralString: ...
540-
@overload
541470
def title(self) -> str: ... # type: ignore[misc]
542471
def translate(self, __table: _TranslateTable) -> str: ...
543-
@overload
544-
def upper(self: LiteralString) -> LiteralString: ...
545-
@overload
546472
def upper(self) -> str: ... # type: ignore[misc]
547-
@overload
548-
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
549-
@overload
550473
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
551474
@staticmethod
552475
@overload
@@ -557,35 +480,20 @@ class str(Sequence[str]):
557480
@staticmethod
558481
@overload
559482
def maketrans(__x: str, __y: str, __z: str) -> dict[int, int | None]: ...
560-
@overload
561-
def __add__(self: LiteralString, __s: LiteralString) -> LiteralString: ...
562-
@overload
563483
def __add__(self, __s: str) -> str: ... # type: ignore[misc]
564484
# Incompatible with Sequence.__contains__
565485
def __contains__(self, __o: str) -> bool: ... # type: ignore[override]
566486
def __eq__(self, __x: object) -> bool: ...
567487
def __ge__(self, __x: str) -> bool: ...
568488
def __getitem__(self, __i: SupportsIndex | slice) -> str: ...
569489
def __gt__(self, __x: str) -> bool: ...
570-
@overload
571-
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
572-
@overload
573490
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
574491
def __le__(self, __x: str) -> bool: ...
575492
def __len__(self) -> int: ...
576493
def __lt__(self, __x: str) -> bool: ...
577-
@overload
578-
def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
579-
@overload
580494
def __mod__(self, __x: Any) -> str: ...
581-
@overload
582-
def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
583-
@overload
584495
def __mul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
585496
def __ne__(self, __x: object) -> bool: ...
586-
@overload
587-
def __rmul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
588-
@overload
589497
def __rmul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
590498
def __getnewargs__(self) -> tuple[str]: ...
591499

0 commit comments

Comments
 (0)