@@ -55,7 +55,7 @@ from typing import ( # noqa: Y027
5555 overload ,
5656 type_check_only ,
5757)
58- from typing_extensions import Literal , SupportsIndex , TypeAlias , TypeGuard , final
58+ from typing_extensions import Literal , LiteralString , SupportsIndex , TypeAlias , TypeGuard , final
5959
6060if sys .version_info >= (3 , 9 ):
6161 from types import GenericAlias
@@ -414,20 +414,38 @@ class str(Sequence[str]):
414414 def __new__ (cls : type [Self ], object : object = ...) -> Self : ...
415415 @overload
416416 def __new__ (cls : type [Self ], object : ReadableBuffer , encoding : str = ..., errors : str = ...) -> Self : ...
417+ @overload
418+ def capitalize (self : LiteralString ) -> LiteralString : ...
419+ @overload
417420 def capitalize (self ) -> str : ... # type: ignore[misc]
421+ @overload
422+ def casefold (self : LiteralString ) -> LiteralString : ...
423+ @overload
418424 def casefold (self ) -> str : ... # type: ignore[misc]
425+ @overload
426+ def center (self : LiteralString , __width : SupportsIndex , __fillchar : LiteralString = ...) -> LiteralString : ...
427+ @overload
419428 def center (self , __width : SupportsIndex , __fillchar : str = ...) -> str : ... # type: ignore[misc]
420429 def count (self , x : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
421430 def encode (self , encoding : str = ..., errors : str = ...) -> bytes : ...
422431 def endswith (
423432 self , __suffix : str | tuple [str , ...], __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...
424433 ) -> bool : ...
425434 if sys .version_info >= (3 , 8 ):
435+ @overload
436+ def expandtabs (self : LiteralString , tabsize : SupportsIndex = ...) -> LiteralString : ...
437+ @overload
426438 def expandtabs (self , tabsize : SupportsIndex = ...) -> str : ... # type: ignore[misc]
427439 else :
440+ @overload
441+ def expandtabs (self : LiteralString , tabsize : int = ...) -> LiteralString : ...
442+ @overload
428443 def expandtabs (self , tabsize : int = ...) -> str : ... # type: ignore[misc]
429444
430445 def find (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
446+ @overload
447+ def format (self : LiteralString , * args : LiteralString , ** kwargs : LiteralString ) -> LiteralString : ...
448+ @overload
431449 def format (self , * args : object , ** kwargs : object ) -> str : ... # type: ignore[misc]
432450 def format_map (self , map : _FormatMapMapping ) -> str : ...
433451 def index (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
@@ -443,53 +461,127 @@ class str(Sequence[str]):
443461 def isspace (self ) -> bool : ...
444462 def istitle (self ) -> bool : ...
445463 def isupper (self ) -> bool : ...
464+ @overload
465+ def join (self : LiteralString , __iterable : Iterable [LiteralString ]) -> LiteralString : ...
466+ @overload
446467 def join (self , __iterable : Iterable [str ]) -> str : ... # type: ignore[misc]
468+ @overload
469+ def ljust (self : LiteralString , __width : SupportsIndex , __fillchar : LiteralString = ...) -> LiteralString : ...
470+ @overload
447471 def ljust (self , __width : SupportsIndex , __fillchar : str = ...) -> str : ... # type: ignore[misc]
472+ @overload
473+ def lower (self : LiteralString ) -> LiteralString : ...
474+ @overload
448475 def lower (self ) -> str : ... # type: ignore[misc]
476+ @overload
477+ def lstrip (self : LiteralString , __chars : LiteralString | None = ...) -> LiteralString : ...
478+ @overload
449479 def lstrip (self , __chars : str | None = ...) -> str : ... # type: ignore[misc]
480+ @overload
481+ def partition (self : LiteralString , __sep : LiteralString ) -> tuple [LiteralString , LiteralString , LiteralString ]: ...
482+ @overload
450483 def partition (self , __sep : str ) -> tuple [str , str , str ]: ... # type: ignore[misc]
484+ @overload
485+ def replace (
486+ self : LiteralString , __old : LiteralString , __new : LiteralString , __count : SupportsIndex = ...
487+ ) -> LiteralString : ...
488+ @overload
451489 def replace (self , __old : str , __new : str , __count : SupportsIndex = ...) -> str : ... # type: ignore[misc]
452490 if sys .version_info >= (3 , 9 ):
491+ @overload
492+ def removeprefix (self : LiteralString , __prefix : LiteralString ) -> LiteralString : ...
493+ @overload
453494 def removeprefix (self , __prefix : str ) -> str : ... # type: ignore[misc]
495+ @overload
496+ def removesuffix (self : LiteralString , __suffix : LiteralString ) -> LiteralString : ...
497+ @overload
454498 def removesuffix (self , __suffix : str ) -> str : ... # type: ignore[misc]
455499
456500 def rfind (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
457501 def rindex (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
502+ @overload
503+ def rjust (self : LiteralString , __width : SupportsIndex , __fillchar : LiteralString = ...) -> LiteralString : ...
504+ @overload
458505 def rjust (self , __width : SupportsIndex , __fillchar : str = ...) -> str : ... # type: ignore[misc]
506+ @overload
507+ def rpartition (self : LiteralString , __sep : LiteralString ) -> tuple [LiteralString , LiteralString , LiteralString ]: ...
508+ @overload
459509 def rpartition (self , __sep : str ) -> tuple [str , str , str ]: ... # type: ignore[misc]
510+ @overload
511+ def rsplit (self : LiteralString , sep : LiteralString | None = ..., maxsplit : SupportsIndex = ...) -> list [LiteralString ]: ...
512+ @overload
460513 def rsplit (self , sep : str | None = ..., maxsplit : SupportsIndex = ...) -> list [str ]: ... # type: ignore[misc]
514+ @overload
515+ def rstrip (self : LiteralString , __chars : LiteralString | None = ...) -> LiteralString : ...
516+ @overload
461517 def rstrip (self , __chars : str | None = ...) -> str : ... # type: ignore[misc]
518+ @overload
519+ def split (self : LiteralString , sep : LiteralString | None = ..., maxsplit : SupportsIndex = ...) -> list [LiteralString ]: ...
520+ @overload
462521 def split (self , sep : str | None = ..., maxsplit : SupportsIndex = ...) -> list [str ]: ... # type: ignore[misc]
522+ @overload
523+ def splitlines (self : LiteralString , keepends : bool = ...) -> list [LiteralString ]: ...
524+ @overload
463525 def splitlines (self , keepends : bool = ...) -> list [str ]: ... # type: ignore[misc]
464526 def startswith (
465527 self , __prefix : str | tuple [str , ...], __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...
466528 ) -> bool : ...
529+ @overload
530+ def strip (self : LiteralString , __chars : LiteralString | None = ...) -> LiteralString : ...
531+ @overload
467532 def strip (self , __chars : str | None = ...) -> str : ... # type: ignore[misc]
533+ @overload
534+ def swapcase (self : LiteralString ) -> LiteralString : ...
535+ @overload
468536 def swapcase (self ) -> str : ... # type: ignore[misc]
537+ @overload
538+ def title (self : LiteralString ) -> LiteralString : ...
539+ @overload
469540 def title (self ) -> str : ... # type: ignore[misc]
470541 def translate (self , __table : _TranslateTable ) -> str : ...
542+ @overload
543+ def upper (self : LiteralString ) -> LiteralString : ...
544+ @overload
471545 def upper (self ) -> str : ... # type: ignore[misc]
546+ @overload
547+ def zfill (self : LiteralString , __width : SupportsIndex ) -> LiteralString : ...
548+ @overload
472549 def zfill (self , __width : SupportsIndex ) -> str : ... # type: ignore[misc]
473550 @staticmethod
474551 @overload
475552 def maketrans (__x : dict [int , _T ] | dict [str , _T ] | dict [str | int , _T ]) -> dict [int , _T ]: ...
476553 @staticmethod
477554 @overload
478555 def maketrans (__x : str , __y : str , __z : str | None = ...) -> dict [int , int | None ]: ...
556+ @overload
557+ def __add__ (self : LiteralString , __s : LiteralString ) -> LiteralString : ...
558+ @overload
479559 def __add__ (self , __s : str ) -> str : ... # type: ignore[misc]
480560 # Incompatible with Sequence.__contains__
481561 def __contains__ (self , __o : str ) -> bool : ... # type: ignore[override]
482562 def __eq__ (self , __x : object ) -> bool : ...
483563 def __ge__ (self , __x : str ) -> bool : ...
484564 def __getitem__ (self , __i : SupportsIndex | slice ) -> str : ...
485565 def __gt__ (self , __x : str ) -> bool : ...
566+ @overload
567+ def __iter__ (self : LiteralString ) -> Iterator [LiteralString ]: ...
568+ @overload
486569 def __iter__ (self ) -> Iterator [str ]: ... # type: ignore[misc]
487570 def __le__ (self , __x : str ) -> bool : ...
488571 def __len__ (self ) -> int : ...
489572 def __lt__ (self , __x : str ) -> bool : ...
573+ @overload
574+ def __mod__ (self : LiteralString , __x : LiteralString | tuple [LiteralString , ...]) -> LiteralString : ...
575+ @overload
490576 def __mod__ (self , __x : Any ) -> str : ... # type: ignore[misc]
577+ @overload
578+ def __mul__ (self : LiteralString , __n : SupportsIndex ) -> LiteralString : ...
579+ @overload
491580 def __mul__ (self , __n : SupportsIndex ) -> str : ... # type: ignore[misc]
492581 def __ne__ (self , __x : object ) -> bool : ...
582+ @overload
583+ def __rmul__ (self : LiteralString , __n : SupportsIndex ) -> LiteralString : ...
584+ @overload
493585 def __rmul__ (self , __n : SupportsIndex ) -> str : ... # type: ignore[misc]
494586 def __getnewargs__ (self ) -> tuple [str ]: ...
495587
0 commit comments