Skip to content

Commit 427987c

Browse files
committed
Revert "Temporarily update typeshed"
This reverts commit 79cb39e.
1 parent 79cb39e commit 427987c

File tree

1 file changed

+2
-114
lines changed

1 file changed

+2
-114
lines changed

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ from typing import ( # noqa: Y022
5656
from typing_extensions import (
5757
Concatenate,
5858
Literal,
59-
LiteralString,
6059
ParamSpec,
6160
Self,
6261
SupportsIndex,
@@ -214,8 +213,6 @@ _NegativeInteger: TypeAlias = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -
214213
_LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
215214

216215
class int:
217-
@overload
218-
def __new__(cls) -> Literal[0]: ...
219216
@overload
220217
def __new__(cls, __x: str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> Self: ...
221218
@overload
@@ -434,44 +431,24 @@ class _TranslateTable(Protocol):
434431
def __getitem__(self, __key: int) -> str | int | None: ...
435432

436433
class str(Sequence[str]):
437-
@overload
438-
def __new__(cls) -> Literal[""]: ...
439434
@overload
440435
def __new__(cls, object: object = ...) -> Self: ...
441436
@overload
442437
def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
443-
@overload
444-
def capitalize(self: LiteralString) -> LiteralString: ...
445-
@overload
446438
def capitalize(self) -> str: ... # type: ignore[misc]
447-
@overload
448-
def casefold(self: LiteralString) -> LiteralString: ...
449-
@overload
450439
def casefold(self) -> str: ... # type: ignore[misc]
451-
@overload
452-
def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
453-
@overload
454440
def center(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
455441
def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
456442
def encode(self, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
457443
def endswith(
458444
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
459445
) -> bool: ...
460446
if sys.version_info >= (3, 8):
461-
@overload
462-
def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...
463-
@overload
464447
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
465448
else:
466-
@overload
467-
def expandtabs(self: LiteralString, tabsize: int = 8) -> LiteralString: ...
468-
@overload
469449
def expandtabs(self, tabsize: int = 8) -> str: ... # type: ignore[misc]
470450

471451
def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
472-
@overload
473-
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
474-
@overload
475452
def format(self, *args: object, **kwargs: object) -> str: ...
476453
def format_map(self, map: _FormatMapMapping) -> str: ...
477454
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
@@ -487,91 +464,32 @@ class str(Sequence[str]):
487464
def isspace(self) -> bool: ...
488465
def istitle(self) -> bool: ...
489466
def isupper(self) -> bool: ...
490-
@overload
491-
def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ...
492-
@overload
493467
def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc]
494-
@overload
495-
def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
496-
@overload
497468
def ljust(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
498-
@overload
499-
def lower(self: LiteralString) -> LiteralString: ...
500-
@overload
501469
def lower(self) -> str: ... # type: ignore[misc]
502-
@overload
503-
def lstrip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
504-
@overload
505470
def lstrip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
506-
@overload
507-
def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
508-
@overload
509471
def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
510-
@overload
511-
def replace(
512-
self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = -1
513-
) -> LiteralString: ...
514-
@overload
515472
def replace(self, __old: str, __new: str, __count: SupportsIndex = -1) -> str: ... # type: ignore[misc]
516473
if sys.version_info >= (3, 9):
517-
@overload
518-
def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ...
519-
@overload
520474
def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc]
521-
@overload
522-
def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ...
523-
@overload
524475
def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc]
525476

526477
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
527478
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
528-
@overload
529-
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = " ") -> LiteralString: ...
530-
@overload
531479
def rjust(self, __width: SupportsIndex, __fillchar: str = " ") -> str: ... # type: ignore[misc]
532-
@overload
533-
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
534-
@overload
535480
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
536-
@overload
537-
def rsplit(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
538-
@overload
539481
def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
540-
@overload
541-
def rstrip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
542-
@overload
543482
def rstrip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
544-
@overload
545-
def split(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
546-
@overload
547483
def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
548-
@overload
549-
def splitlines(self: LiteralString, keepends: bool = False) -> list[LiteralString]: ...
550-
@overload
551484
def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]
552485
def startswith(
553486
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
554487
) -> bool: ...
555-
@overload
556-
def strip(self: LiteralString, __chars: LiteralString | None = None) -> LiteralString: ...
557-
@overload
558488
def strip(self, __chars: str | None = None) -> str: ... # type: ignore[misc]
559-
@overload
560-
def swapcase(self: LiteralString) -> LiteralString: ...
561-
@overload
562489
def swapcase(self) -> str: ... # type: ignore[misc]
563-
@overload
564-
def title(self: LiteralString) -> LiteralString: ...
565-
@overload
566490
def title(self) -> str: ... # type: ignore[misc]
567491
def translate(self, __table: _TranslateTable) -> str: ...
568-
@overload
569-
def upper(self: LiteralString) -> LiteralString: ...
570-
@overload
571492
def upper(self) -> str: ... # type: ignore[misc]
572-
@overload
573-
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
574-
@overload
575493
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
576494
@staticmethod
577495
@overload
@@ -582,9 +500,6 @@ class str(Sequence[str]):
582500
@staticmethod
583501
@overload
584502
def maketrans(__x: str, __y: str, __z: str) -> dict[int, int | None]: ...
585-
@overload
586-
def __add__(self: LiteralString, __value: LiteralString) -> LiteralString: ...
587-
@overload
588503
def __add__(self, __value: str) -> str: ... # type: ignore[misc]
589504
# Incompatible with Sequence.__contains__
590505
def __contains__(self, __key: str) -> bool: ... # type: ignore[override]
@@ -593,31 +508,17 @@ class str(Sequence[str]):
593508
def __getitem__(self, __key: SupportsIndex | slice) -> str: ...
594509
def __gt__(self, __value: str) -> bool: ...
595510
def __hash__(self) -> int: ...
596-
@overload
597-
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
598-
@overload
599511
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
600512
def __le__(self, __value: str) -> bool: ...
601513
def __len__(self) -> int: ...
602514
def __lt__(self, __value: str) -> bool: ...
603-
@overload
604-
def __mod__(self: LiteralString, __value: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
605-
@overload
606515
def __mod__(self, __value: Any) -> str: ...
607-
@overload
608-
def __mul__(self: LiteralString, __value: SupportsIndex) -> LiteralString: ...
609-
@overload
610516
def __mul__(self, __value: SupportsIndex) -> str: ... # type: ignore[misc]
611517
def __ne__(self, __value: object) -> bool: ...
612-
@overload
613-
def __rmul__(self: LiteralString, __value: SupportsIndex) -> LiteralString: ...
614-
@overload
615518
def __rmul__(self, __value: SupportsIndex) -> str: ... # type: ignore[misc]
616519
def __getnewargs__(self) -> tuple[str]: ...
617520

618521
class bytes(Sequence[int]):
619-
@overload
620-
def __new__(cls) -> Literal[b""]: ...
621522
@overload
622523
def __new__(cls, __o: Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer) -> Self: ...
623524
@overload
@@ -904,21 +805,8 @@ class memoryview(Sequence[int]):
904805
def __buffer__(self, __flags: int) -> memoryview: ...
905806
def __release_buffer__(self, __buffer: memoryview) -> None: ...
906807

907-
class _Truthy(Protocol):
908-
def __bool__(self) -> Literal[True]: ...
909-
910-
class _Falsy(Protocol):
911-
def __bool__(self) -> Literal[False]: ...
912-
913808
@final
914809
class bool(int):
915-
@overload
916-
def __new__(cls) -> Literal[False]: ...
917-
@overload
918-
def __new__(cls, __o: _Truthy) -> Literal[True]: ...
919-
@overload
920-
def __new__(cls, __o: _Falsy) -> Literal[False]: ...
921-
@overload
922810
def __new__(cls, __o: object = ...) -> Self: ...
923811
# The following overloads could be represented more elegantly with a TypeVar("_B", bool, int),
924812
# however mypy has a bug regarding TypeVar constraints (https://github.com/python/mypy/issues/11880).
@@ -1788,11 +1676,11 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
17881676
# Instead, we special-case the most common examples of this: bool and literal integers.
17891677
if sys.version_info >= (3, 8):
17901678
@overload
1791-
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = 0) -> int: ... # type: ignore[misc]
1679+
def sum(__iterable: Iterable[bool], start: int = 0) -> int: ... # type: ignore[misc]
17921680

17931681
else:
17941682
@overload
1795-
def sum(__iterable: Iterable[bool | _LiteralInteger], __start: int = 0) -> int: ... # type: ignore[misc]
1683+
def sum(__iterable: Iterable[bool], __start: int = 0) -> int: ... # type: ignore[misc]
17961684

17971685
@overload
17981686
def sum(__iterable: Iterable[_SupportsSumNoDefaultT]) -> _SupportsSumNoDefaultT | Literal[0]: ...

0 commit comments

Comments
 (0)