@@ -67,7 +67,9 @@ class Match(Generic[AnyStr]):
6767 @overload
6868 def expand (self : Match [str ], template : str ) -> str : ...
6969 @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 : ...
7173 # group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
7274 @overload
7375 def group (self , __group : Literal [0 ] = ...) -> AnyStr : ...
@@ -115,46 +117,62 @@ class Pattern(Generic[AnyStr]):
115117 @overload
116118 def search (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Match [str ] | None : ...
117119 @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 : ...
119123 @overload
120124 def match (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Match [str ] | None : ...
121125 @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 : ...
123129 @overload
124130 def fullmatch (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Match [str ] | None : ...
125131 @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 : ...
127135 @overload
128136 def split (self : Pattern [str ], string : str , maxsplit : int = ...) -> list [str | Any ]: ...
129137 @overload
130138 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 ]: ...
131141 # return type depends on the number of groups in the pattern
132142 @overload
133143 def findall (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> list [Any ]: ...
134144 @overload
135145 def findall (self : Pattern [bytes ], string : ReadableBuffer , pos : int = ..., endpos : int = ...) -> list [Any ]: ...
136146 @overload
147+ def findall (self , string : AnyStr , pos : int = ..., endpos : int = ...) -> list [AnyStr ]: ...
148+ @overload
137149 def finditer (self : Pattern [str ], string : str , pos : int = ..., endpos : int = ...) -> Iterator [Match [str ]]: ...
138150 @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 ]]: ...
140154 @overload
141155 def sub (self : Pattern [str ], repl : str | Callable [[Match [str ]], str ], string : str , count : int = ...) -> str : ...
142156 @overload
143- def sub (
157+ def sub ( # type: ignore[misc]
144158 self : Pattern [bytes ],
145159 repl : ReadableBuffer | Callable [[Match [bytes ]], ReadableBuffer ],
146160 string : ReadableBuffer ,
147161 count : int = ...,
148162 ) -> bytes : ...
149163 @overload
164+ def sub (self , repl : AnyStr | Callable [[Match [AnyStr ]], AnyStr ], string : AnyStr , count : int = ...) -> AnyStr : ...
165+ @overload
150166 def subn (self : Pattern [str ], repl : str | Callable [[Match [str ]], str ], string : str , count : int = ...) -> tuple [str , int ]: ...
151167 @overload
152- def subn (
168+ def subn ( # type: ignore[misc]
153169 self : Pattern [bytes ],
154170 repl : ReadableBuffer | Callable [[Match [bytes ]], ReadableBuffer ],
155171 string : ReadableBuffer ,
156172 count : int = ...,
157173 ) -> tuple [bytes , int ]: ...
174+ @overload
175+ def subn (self , repl : AnyStr | Callable [[Match [AnyStr ]], AnyStr ], string : AnyStr , count : int = ...) -> tuple [AnyStr , int ]: ...
158176 def __copy__ (self ) -> Pattern [AnyStr ]: ...
159177 def __deepcopy__ (self , __memo : Any ) -> Pattern [AnyStr ]: ...
160178 if sys .version_info >= (3 , 9 ):
0 commit comments