@@ -67,7 +67,9 @@ class Match(Generic[AnyStr]):
67
67
@overload
68
68
def expand (self : Match [str ], template : str ) -> str : ...
69
69
@overload
70
- def expand (self : Match [bytes ], template : ReadableBuffer ) -> bytes : ...
70
+ def expand (self : Match [bytes ], template : ReadableBuffer ) -> bytes : ... # type: ignore[misc]
71
+ @overload
72
+ def expand (self , template : AnyStr ) -> AnyStr : ...
71
73
# group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
72
74
@overload
73
75
def group (self , __group : Literal [0 ] = ...) -> AnyStr : ...
@@ -115,46 +117,62 @@ class Pattern(Generic[AnyStr]):
115
117
@overload
116
118
def search (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Match [str ] | None : ...
117
119
@overload
118
- def search (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Match [bytes ] | None : ...
120
+ def search (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Match [bytes ] | None : ... # type: ignore[misc]
121
+ @overload
122
+ def search (self , string : AnyStr , pos : int = ..., endpos : int = ...) -> Match [AnyStr ] | None : ...
119
123
@overload
120
124
def match (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Match [str ] | None : ...
121
125
@overload
122
- def match (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Match [bytes ] | None : ...
126
+ def match (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Match [bytes ] | None : ... # type: ignore[misc]
127
+ @overload
128
+ def match (self , string : AnyStr , pos : int = ..., endpos : int = ...) -> Match [AnyStr ] | None : ...
123
129
@overload
124
130
def fullmatch (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Match [str ] | None : ...
125
131
@overload
126
- def fullmatch (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Match [bytes ] | None : ...
132
+ def fullmatch (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Match [bytes ] | None : ... # type: ignore[misc]
133
+ @overload
134
+ def fullmatch (self , string : AnyStr , pos : int = ..., endpos : int = ...) -> Match [AnyStr ] | None : ...
127
135
@overload
128
136
def split (self : Pattern [str ], string : str , maxsplit : int = ...) -> list [str | Any ]: ...
129
137
@overload
130
138
def split (self : Pattern [bytes ], string : ReadableBuffer , maxsplit : int = ...) -> list [bytes | Any ]: ...
139
+ @overload
140
+ def split (self , string : AnyStr , maxsplit : int = ...) -> list [AnyStr | Any ]: ...
131
141
# return type depends on the number of groups in the pattern
132
142
@overload
133
143
def findall (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> list [Any ]: ...
134
144
@overload
135
145
def findall (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> list [Any ]: ...
136
146
@overload
147
+ def findall (self , string : AnyStr , pos : int = ..., endpos : int = ...) -> list [AnyStr ]: ...
148
+ @overload
137
149
def finditer (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Iterator [Match [str ]]: ...
138
150
@overload
139
- def finditer (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Iterator [Match [bytes ]]: ...
151
+ def finditer (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> Iterator [Match [bytes ]]: ... # type: ignore[misc]
152
+ @overload
153
+ def finditer (self , string : AnyStr , pos : int = ..., endpos : int = ...) -> Iterator [Match [AnyStr ]]: ...
140
154
@overload
141
155
def sub (self : Pattern [str ], repl : str | Callable [[Match [str ]], str ], string : str , count : int = ...) -> str : ...
142
156
@overload
143
- def sub (
157
+ def sub ( # type: ignore[misc]
144
158
self : Pattern [bytes ],
145
159
repl : ReadableBuffer | Callable [[Match [bytes ]], ReadableBuffer ],
146
160
string : ReadableBuffer ,
147
161
count : int = ...,
148
162
) -> bytes : ...
149
163
@overload
164
+ def sub (self , repl : AnyStr | Callable [[Match [AnyStr ]], AnyStr ], string : AnyStr , count : int = ...) -> AnyStr : ...
165
+ @overload
150
166
def subn (self : Pattern [str ], repl : str | Callable [[Match [str ]], str ], string : str , count : int = ...) -> tuple [str , int ]: ...
151
167
@overload
152
- def subn (
168
+ def subn ( # type: ignore[misc]
153
169
self : Pattern [bytes ],
154
170
repl : ReadableBuffer | Callable [[Match [bytes ]], ReadableBuffer ],
155
171
string : ReadableBuffer ,
156
172
count : int = ...,
157
173
) -> tuple [bytes , int ]: ...
174
+ @overload
175
+ def subn (self , repl : AnyStr | Callable [[Match [AnyStr ]], AnyStr ], string : AnyStr , count : int = ...) -> tuple [AnyStr , int ]: ...
158
176
def __copy__ (self ) -> Pattern [AnyStr ]: ...
159
177
def __deepcopy__ (self , __memo : Any ) -> Pattern [AnyStr ]: ...
160
178
if sys .version_info >= (3 , 9 ):
0 commit comments