1
1
import sys
2
+ from _typeshed import StrOrLiteralStr
2
3
from collections .abc import Iterable , Mapping , Sequence
3
4
from re import Pattern , RegexFlag
4
- from typing import Any
5
+ from typing import Any , overload
6
+ from typing_extensions import LiteralString
5
7
6
8
__all__ = [
7
9
"ascii_letters" ,
@@ -18,17 +20,17 @@ __all__ = [
18
20
"Template" ,
19
21
]
20
22
21
- ascii_letters : str
22
- ascii_lowercase : str
23
- ascii_uppercase : str
24
- digits : str
25
- hexdigits : str
26
- octdigits : str
27
- punctuation : str
28
- printable : str
29
- whitespace : str
23
+ ascii_letters : LiteralString
24
+ ascii_lowercase : LiteralString
25
+ ascii_uppercase : LiteralString
26
+ digits : LiteralString
27
+ hexdigits : LiteralString
28
+ octdigits : LiteralString
29
+ punctuation : LiteralString
30
+ printable : LiteralString
31
+ whitespace : LiteralString
30
32
31
- def capwords (s : str , sep : str | None = ...) -> str : ...
33
+ def capwords (s : StrOrLiteralStr , sep : StrOrLiteralStr | None = ...) -> StrOrLiteralStr : ...
32
34
33
35
class Template :
34
36
template : str
@@ -46,9 +48,19 @@ class Template:
46
48
47
49
# TODO(MichalPokorny): This is probably badly and/or loosely typed.
48
50
class Formatter :
51
+ @overload
52
+ def format (self , __format_string : LiteralString , * args : LiteralString , ** kwargs : LiteralString ) -> LiteralString : ...
53
+ @overload
49
54
def format (self , __format_string : str , * args : Any , ** kwargs : Any ) -> str : ...
55
+ @overload
56
+ def vformat (
57
+ self , format_string : LiteralString , args : Sequence [LiteralString ], kwargs : Mapping [LiteralString , LiteralString ]
58
+ ) -> LiteralString : ...
59
+ @overload
50
60
def vformat (self , format_string : str , args : Sequence [Any ], kwargs : Mapping [str , Any ]) -> str : ...
51
- def parse (self , format_string : str ) -> Iterable [tuple [str , str | None , str | None , str | None ]]: ...
61
+ def parse (
62
+ self , format_string : StrOrLiteralStr
63
+ ) -> Iterable [tuple [StrOrLiteralStr , StrOrLiteralStr | None , StrOrLiteralStr | None , StrOrLiteralStr | None ]]: ...
52
64
def get_field (self , field_name : str , args : Sequence [Any ], kwargs : Mapping [str , Any ]) -> Any : ...
53
65
def get_value (self , key : int | str , args : Sequence [Any ], kwargs : Mapping [str , Any ]) -> Any : ...
54
66
def check_unused_args (self , used_args : Sequence [int | str ], args : Sequence [Any ], kwargs : Mapping [str , Any ]) -> None : ...
0 commit comments