@@ -49,7 +49,7 @@ from typing import ( # noqa: Y027
49
49
TypeVar ,
50
50
overload ,
51
51
)
52
- from typing_extensions import Literal , SupportsIndex , TypeAlias , TypeGuard , final
52
+ from typing_extensions import Literal , LiteralString , SupportsIndex , TypeAlias , TypeGuard , final
53
53
54
54
if sys .version_info >= (3 , 9 ):
55
55
from types import GenericAlias
@@ -394,20 +394,38 @@ class str(Sequence[str]):
394
394
def __new__ (cls : type [Self ], object : object = ...) -> Self : ...
395
395
@overload
396
396
def __new__ (cls : type [Self ], object : ReadableBuffer , encoding : str = ..., errors : str = ...) -> Self : ...
397
+ @overload
398
+ def capitalize (self : LiteralString ) -> LiteralString : ...
399
+ @overload
397
400
def capitalize (self ) -> str : ...
401
+ @overload
402
+ def casefold (self : LiteralString ) -> LiteralString : ...
403
+ @overload
398
404
def casefold (self ) -> str : ...
405
+ @overload
406
+ def center (self : LiteralString , __width : SupportsIndex , __fillchar : LiteralString = ...) -> LiteralString : ...
407
+ @overload
399
408
def center (self , __width : SupportsIndex , __fillchar : str = ...) -> str : ...
400
409
def count (self , x : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
401
410
def encode (self , encoding : str = ..., errors : str = ...) -> bytes : ...
402
411
def endswith (
403
412
self , __suffix : str | tuple [str , ...], __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...
404
413
) -> bool : ...
405
414
if sys .version_info >= (3 , 8 ):
415
+ @overload
416
+ def expandtabs (self : LiteralString , tabsize : SupportsIndex = ...) -> LiteralString : ...
417
+ @overload
406
418
def expandtabs (self , tabsize : SupportsIndex = ...) -> str : ...
407
419
else :
420
+ @overload
421
+ def expandtabs (self : LiteralString , tabsize : int = ...) -> LiteralString : ...
422
+ @overload
408
423
def expandtabs (self , tabsize : int = ...) -> str : ...
409
424
410
425
def find (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
426
+ @overload
427
+ def format (self : LiteralString , * args : LiteralString , ** kwargs : LiteralString ) -> LiteralString : ...
428
+ @overload
411
429
def format (self , * args : object , ** kwargs : object ) -> str : ...
412
430
def format_map (self , map : _FormatMapMapping ) -> str : ...
413
431
def index (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
@@ -425,39 +443,99 @@ class str(Sequence[str]):
425
443
def isspace (self ) -> bool : ...
426
444
def istitle (self ) -> bool : ...
427
445
def isupper (self ) -> bool : ...
446
+ @overload
447
+ def join (self : LiteralString , __iterable : Iterable [LiteralString ]) -> LiteralString : ...
448
+ @overload
428
449
def join (self , __iterable : Iterable [str ]) -> str : ...
450
+ @overload
451
+ def ljust (self : LiteralString , __width : SupportsIndex , __fillchar : LiteralString = ...) -> LiteralString : ...
452
+ @overload
429
453
def ljust (self , __width : SupportsIndex , __fillchar : str = ...) -> str : ...
454
+ @overload
455
+ def lower (self : LiteralString ) -> LiteralString : ...
456
+ @overload
430
457
def lower (self ) -> str : ...
458
+ @overload
459
+ def lstrip (self : LiteralString , __chars : LiteralString | None = ...) -> LiteralString : ...
460
+ @overload
431
461
def lstrip (self , __chars : str | None = ...) -> str : ...
462
+ @overload
463
+ def partition (self : LiteralString , __sep : LiteralString ) -> tuple [LiteralString , LiteralString , LiteralString ]: ...
464
+ @overload
432
465
def partition (self , __sep : str ) -> tuple [str , str , str ]: ...
466
+ @overload
467
+ def replace (self : LiteralString , __old : LiteralString , __new : LiteralString , __count : SupportsIndex = ...) -> LiteralString : ...
468
+ @overload
433
469
def replace (self , __old : str , __new : str , __count : SupportsIndex = ...) -> str : ...
434
470
if sys .version_info >= (3 , 9 ):
471
+ @overload
472
+ def removeprefix (self : LiteralString , __prefix : LiteralString ) -> LiteralString : ...
473
+ @overload
435
474
def removeprefix (self , __prefix : str ) -> str : ...
475
+ @overload
476
+ def removesuffix (self : LiteralString , __suffix : LiteralString ) -> LiteralString : ...
477
+ @overload
436
478
def removesuffix (self , __suffix : str ) -> str : ...
437
479
438
480
def rfind (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
439
481
def rindex (self , __sub : str , __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...) -> int : ...
482
+ @overload
483
+ def rjust (self : LiteralString , __width : SupportsIndex , __fillchar : LiteralString = ...) -> LiteralString : ...
484
+ @overload
440
485
def rjust (self , __width : SupportsIndex , __fillchar : str = ...) -> str : ...
486
+ @overload
487
+ def rpartition (self : LiteralString , __sep : LiteralString ) -> tuple [LiteralString , LiteralString , LiteralString ]: ...
488
+ @overload
441
489
def rpartition (self , __sep : str ) -> tuple [str , str , str ]: ...
490
+ @overload
491
+ def rsplit (self : LiteralString , sep : LiteralString | None = ..., maxsplit : SupportsIndex = ...) -> list [LiteralString ]: ...
492
+ @overload
442
493
def rsplit (self , sep : str | None = ..., maxsplit : SupportsIndex = ...) -> list [str ]: ...
494
+ @overload
495
+ def rstrip (self : LiteralString , __chars : LiteralString | None = ...) -> LiteralString : ...
496
+ @overload
443
497
def rstrip (self , __chars : str | None = ...) -> str : ...
498
+ @overload
499
+ def split (self : LiteralString , sep : LiteralString | None = ..., maxsplit : SupportsIndex = ...) -> list [LiteralString ]: ...
500
+ @overload
444
501
def split (self , sep : str | None = ..., maxsplit : SupportsIndex = ...) -> list [str ]: ...
502
+ @overload
503
+ def splitlines (self : LiteralString , keepends : bool = ...) -> list [LiteralString ]: ...
504
+ @overload
445
505
def splitlines (self , keepends : bool = ...) -> list [str ]: ...
446
506
def startswith (
447
507
self , __prefix : str | tuple [str , ...], __start : SupportsIndex | None = ..., __end : SupportsIndex | None = ...
448
508
) -> bool : ...
509
+ @overload
510
+ def strip (self : LiteralString , __chars : LiteralString | None = ...) -> LiteralString : ...
511
+ @overload
449
512
def strip (self , __chars : str | None = ...) -> str : ...
513
+ @overload
514
+ def swapcase (self : LiteralString ) -> LiteralString : ...
515
+ @overload
450
516
def swapcase (self ) -> str : ...
517
+ @overload
518
+ def title (self : LiteralString ) -> LiteralString : ...
519
+ @overload
451
520
def title (self ) -> str : ...
452
521
def translate (self , __table : Mapping [int , int | str | None ] | Sequence [int | str | None ]) -> str : ...
522
+ @overload
523
+ def upper (self : LiteralString ) -> LiteralString : ...
524
+ @overload
453
525
def upper (self ) -> str : ...
526
+ @overload
527
+ def zfill (self : LiteralString , __width : SupportsIndex ) -> LiteralString : ...
528
+ @overload
454
529
def zfill (self , __width : SupportsIndex ) -> str : ...
455
530
@staticmethod
456
531
@overload
457
532
def maketrans (__x : dict [int , _T ] | dict [str , _T ] | dict [str | int , _T ]) -> dict [int , _T ]: ...
458
533
@staticmethod
459
534
@overload
460
535
def maketrans (__x : str , __y : str , __z : str | None = ...) -> dict [int , int | None ]: ...
536
+ @overload
537
+ def __add__ (self : LiteralString , __s : LiteralString ) -> LiteralString : ...
538
+ @overload
461
539
def __add__ (self , __s : str ) -> str : ...
462
540
# Incompatible with Sequence.__contains__
463
541
def __contains__ (self , __o : str ) -> bool : ... # type: ignore[override]
@@ -466,11 +544,20 @@ class str(Sequence[str]):
466
544
def __getitem__ (self , __i : SupportsIndex | slice ) -> str : ...
467
545
def __gt__ (self , __x : str ) -> bool : ...
468
546
def __hash__ (self ) -> int : ...
547
+ @overload
548
+ def __iter__ (self : LiteralString ) -> Iterator [LiteralString ]: ...
549
+ @overload
469
550
def __iter__ (self ) -> Iterator [str ]: ...
470
551
def __le__ (self , __x : str ) -> bool : ...
471
552
def __len__ (self ) -> int : ...
472
553
def __lt__ (self , __x : str ) -> bool : ...
554
+ @overload
555
+ def __mod__ (self : LiteralString , __x : LiteralString | tuple [LiteralString , ...]) -> LiteralString : ...
556
+ @overload
473
557
def __mod__ (self , __x : Any ) -> str : ...
558
+ @overload
559
+ def __mul__ (self : LiteralString , __n : SupportsIndex ) -> LiteralString : ...
560
+ @overload
474
561
def __mul__ (self , __n : SupportsIndex ) -> str : ...
475
562
def __ne__ (self , __x : object ) -> bool : ...
476
563
def __rmul__ (self , __n : SupportsIndex ) -> str : ...
0 commit comments