Skip to content

Commit 250e6fd

Browse files
hauntsaninjaJelleZijlstra
authored andcommitted
Remove use of LiteralString in builtins (#13743)
1 parent 85dac76 commit 250e6fd

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 Concatenate, Literal, LiteralString, ParamSpec, Self, SupportsIndex, TypeAlias, TypeGuard, final
57+
from typing_extensions import Concatenate, Literal, ParamSpec, Self, SupportsIndex, TypeAlias, TypeGuard, final
5858

5959
if sys.version_info >= (3, 9):
6060
from types import GenericAlias
@@ -416,38 +416,20 @@ class str(Sequence[str]):
416416
def __new__(cls, object: object = ...) -> Self: ...
417417
@overload
418418
def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
419-
@overload
420-
def capitalize(self: LiteralString) -> LiteralString: ...
421-
@overload
422419
def capitalize(self) -> str: ... # type: ignore[misc]
423-
@overload
424-
def casefold(self: LiteralString) -> LiteralString: ...
425-
@overload
426420
def casefold(self) -> str: ... # type: ignore[misc]
427-
@overload
428-
def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
429-
@overload
430421
def center(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
431422
def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
432423
def encode(self, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
433424
def endswith(
434425
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
435426
) -> bool: ...
436427
if sys.version_info >= (3, 8):
437-
@overload
438-
def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...
439-
@overload
440428
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
441429
else:
442-
@overload
443-
def expandtabs(self: LiteralString, tabsize: int = 8) -> LiteralString: ...
444-
@overload
445430
def expandtabs(self, tabsize: int = 8) -> str: ... # type: ignore[misc]
446431

447432
def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
448-
@overload
449-
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
450-
@overload
451433
def format(self, *args: object, **kwargs: object) -> str: ...
452434
def format_map(self, map: _FormatMapMapping) -> str: ...
453435
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
@@ -463,91 +445,32 @@ class str(Sequence[str]):
463445
def isspace(self) -> bool: ...
464446
def istitle(self) -> bool: ...
465447
def isupper(self) -> bool: ...
466-
@overload
467-
def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ...
468-
@overload
469448
def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc]
470-
@overload
471-
def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
472-
@overload
473449
def ljust(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
474-
@overload
475-
def lower(self: LiteralString) -> LiteralString: ...
476-
@overload
477450
def lower(self) -> str: ... # type: ignore[misc]
478-
@overload
479-
def lstrip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
480-
@overload
481451
def lstrip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
482-
@overload
483-
def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
484-
@overload
485452
def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
486-
@overload
487-
def replace(
488-
self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = -1
489-
) -> LiteralString: ...
490-
@overload
491453
def replace(self, __old: str, __new: str, __count: SupportsIndex = -1) -> str: ... # type: ignore[misc]
492454
if sys.version_info >= (3, 9):
493-
@overload
494-
def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ...
495-
@overload
496455
def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc]
497-
@overload
498-
def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ...
499-
@overload
500456
def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc]
501457

502458
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
503459
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
504-
@overload
505-
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
506-
@overload
507460
def rjust(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
508-
@overload
509-
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
510-
@overload
511461
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
512-
@overload
513-
def rsplit(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
514-
@overload
515462
def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
516-
@overload
517-
def rstrip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
518-
@overload
519463
def rstrip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
520-
@overload
521-
def split(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
522-
@overload
523464
def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
524-
@overload
525-
def splitlines(self: LiteralString, keepends: bool = False) -> list[LiteralString]: ...
526-
@overload
527465
def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]
528466
def startswith(
529467
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
530468
) -> bool: ...
531-
@overload
532-
def strip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
533-
@overload
534469
def strip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
535-
@overload
536-
def swapcase(self: LiteralString) -> LiteralString: ...
537-
@overload
538470
def swapcase(self) -> str: ... # type: ignore[misc]
539-
@overload
540-
def title(self: LiteralString) -> LiteralString: ...
541-
@overload
542471
def title(self) -> str: ... # type: ignore[misc]
543472
def translate(self, __table: _TranslateTable) -> str: ...
544-
@overload
545-
def upper(self: LiteralString) -> LiteralString: ...
546-
@overload
547473
def upper(self) -> str: ... # type: ignore[misc]
548-
@overload
549-
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
550-
@overload
551474
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
552475
@staticmethod
553476
@overload
@@ -558,35 +481,20 @@ class str(Sequence[str]):
558481
@staticmethod
559482
@overload
560483
def maketrans(__x: str, __y: str, __z: str) -> dict[int, int | None]: ...
561-
@overload
562-
def __add__(self: LiteralString, __value: LiteralString) -> LiteralString: ...
563-
@overload
564484
def __add__(self, __value: str) -> str: ... # type: ignore[misc]
565485
# Incompatible with Sequence.__contains__
566486
def __contains__(self, __key: str) -> bool: ... # type: ignore[override]
567487
def __eq__(self, __value: object) -> bool: ...
568488
def __ge__(self, __value: str) -> bool: ...
569489
def __getitem__(self, __key: SupportsIndex | slice) -> str: ...
570490
def __gt__(self, __value: str) -> bool: ...
571-
@overload
572-
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
573-
@overload
574491
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
575492
def __le__(self, __value: str) -> bool: ...
576493
def __len__(self) -> int: ...
577494
def __lt__(self, __value: str) -> bool: ...
578-
@overload
579-
def __mod__(self: LiteralString, __value: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
580-
@overload
581495
def __mod__(self, __value: Any) -> str: ...
582-
@overload
583-
def __mul__(self: LiteralString, __value: SupportsIndex) -> LiteralString: ...
584-
@overload
585496
def __mul__(self, __value: SupportsIndex) -> str: ... # type: ignore[misc]
586497
def __ne__(self, __value: object) -> bool: ...
587-
@overload
588-
def __rmul__(self: LiteralString, __value: SupportsIndex) -> LiteralString: ...
589-
@overload
590498
def __rmul__(self, __value: SupportsIndex) -> str: ... # type: ignore[misc]
591499
def __getnewargs__(self) -> tuple[str]: ...
592500

0 commit comments

Comments
 (0)