44import sys
55from _ast import *
66from collections .abc import Iterator
7- from typing import Any , TypeVar , overload
8- from typing_extensions import Literal
7+ from typing import Any , TypeVar , overload , Literal , Union , Optional
98
109if sys .version_info >= (3 , 8 ):
1110 class _ABC (type ):
@@ -160,87 +159,87 @@ _T = TypeVar("_T", bound=AST)
160159if sys .version_info >= (3 , 8 ):
161160 @overload
162161 def parse (
163- source : str | bytes ,
164- filename : str | bytes = ...,
162+ source : Union [ str , bytes ] ,
163+ filename : Union [ str , bytes ] = ...,
165164 mode : Literal ["exec" ] = ...,
166165 * ,
167166 type_comments : bool = ...,
168- feature_version : None | int | tuple [int , int ] = ...,
167+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
169168 ) -> Module : ...
170169 @overload
171170 def parse (
172- source : str | bytes ,
173- filename : str | bytes ,
171+ source : Union [ str , bytes ] ,
172+ filename : Union [ str , bytes ] ,
174173 mode : Literal ["eval" ],
175174 * ,
176175 type_comments : bool = ...,
177- feature_version : None | int | tuple [int , int ] = ...,
176+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
178177 ) -> Expression : ...
179178 @overload
180179 def parse (
181- source : str | bytes ,
182- filename : str | bytes ,
180+ source : Union [ str , bytes ] ,
181+ filename : Union [ str , bytes ] ,
183182 mode : Literal ["func_type" ],
184183 * ,
185184 type_comments : bool = ...,
186- feature_version : None | int | tuple [int , int ] = ...,
185+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
187186 ) -> FunctionType : ...
188187 @overload
189188 def parse (
190- source : str | bytes ,
191- filename : str | bytes ,
189+ source : Union [ str , bytes ] ,
190+ filename : Union [ str , bytes ] ,
192191 mode : Literal ["single" ],
193192 * ,
194193 type_comments : bool = ...,
195- feature_version : None | int | tuple [int , int ] = ...,
194+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
196195 ) -> Interactive : ...
197196 @overload
198197 def parse (
199- source : str | bytes ,
198+ source : Union [ str , bytes ] ,
200199 * ,
201200 mode : Literal ["eval" ],
202201 type_comments : bool = ...,
203- feature_version : None | int | tuple [int , int ] = ...,
202+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
204203 ) -> Expression : ...
205204 @overload
206205 def parse (
207- source : str | bytes ,
206+ source : Union [ str , bytes ] ,
208207 * ,
209208 mode : Literal ["func_type" ],
210209 type_comments : bool = ...,
211- feature_version : None | int | tuple [int , int ] = ...,
210+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
212211 ) -> FunctionType : ...
213212 @overload
214213 def parse (
215- source : str | bytes ,
214+ source : Union [ str , bytes ] ,
216215 * ,
217216 mode : Literal ["single" ],
218217 type_comments : bool = ...,
219- feature_version : None | int | tuple [int , int ] = ...,
218+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
220219 ) -> Interactive : ...
221220 @overload
222221 def parse (
223- source : str | bytes ,
224- filename : str | bytes = ...,
222+ source : Union [ str , bytes ] ,
223+ filename : Union [ str , bytes ] = ...,
225224 mode : str = ...,
226225 * ,
227226 type_comments : bool = ...,
228- feature_version : None | int | tuple [int , int ] = ...,
227+ feature_version : Optional [ Union [ int , tuple [int , int ]] ] = ...,
229228 ) -> AST : ...
230229
231230else :
232231 @overload
233- def parse (source : str | bytes , filename : str | bytes = ..., mode : Literal ["exec" ] = ...) -> Module : ...
232+ def parse (source : Union [ str , bytes ] , filename : Union [ str , bytes ] = ..., mode : Literal ["exec" ] = ...) -> Module : ...
234233 @overload
235- def parse (source : str | bytes , filename : str | bytes , mode : Literal ["eval" ]) -> Expression : ...
234+ def parse (source : Union [ str , bytes ] , filename : Union [ str , bytes ] , mode : Literal ["eval" ]) -> Expression : ...
236235 @overload
237- def parse (source : str | bytes , filename : str | bytes , mode : Literal ["single" ]) -> Interactive : ...
236+ def parse (source : Union [ str , bytes ] , filename : Union [ str , bytes ] , mode : Literal ["single" ]) -> Interactive : ...
238237 @overload
239- def parse (source : str | bytes , * , mode : Literal ["eval" ]) -> Expression : ...
238+ def parse (source : Union [ str , bytes ] , * , mode : Literal ["eval" ]) -> Expression : ...
240239 @overload
241- def parse (source : str | bytes , * , mode : Literal ["single" ]) -> Interactive : ...
240+ def parse (source : Union [ str , bytes ] , * , mode : Literal ["single" ]) -> Interactive : ...
242241 @overload
243- def parse (source : str | bytes , filename : str | bytes = ..., mode : str = ...) -> AST : ...
242+ def parse (source : Union [ str , bytes ] , filename : Union [ str , bytes ] = ..., mode : str = ...) -> AST : ...
244243
245244if sys .version_info >= (3 , 9 ):
246245 def unparse (ast_obj : AST ) -> str : ...
@@ -249,21 +248,21 @@ def copy_location(new_node: _T, old_node: AST) -> _T: ...
249248
250249if sys .version_info >= (3 , 9 ):
251250 def dump (
252- node : AST , annotate_fields : bool = ..., include_attributes : bool = ..., * , indent : int | str | None = ...
251+ node : AST , annotate_fields : bool = ..., include_attributes : bool = ..., * , indent : Optional [ Union [ int , str ]] = ...
253252 ) -> str : ...
254253
255254else :
256255 def dump (node : AST , annotate_fields : bool = ..., include_attributes : bool = ...) -> str : ...
257256
258257def fix_missing_locations (node : _T ) -> _T : ...
259- def get_docstring (node : AST , clean : bool = ...) -> str | None : ...
258+ def get_docstring (node : AST , clean : bool = ...) -> Optional [ str ] : ...
260259def increment_lineno (node : _T , n : int = ...) -> _T : ...
261260def iter_child_nodes (node : AST ) -> Iterator [AST ]: ...
262261def iter_fields (node : AST ) -> Iterator [tuple [str , Any ]]: ...
263- def literal_eval (node_or_string : str | AST ) -> Any : ...
262+ def literal_eval (node_or_string : Union [ str , AST ] ) -> Any : ...
264263
265264if sys .version_info >= (3 , 8 ):
266- def get_source_segment (source : str , node : AST , * , padded : bool = ...) -> str | None : ...
265+ def get_source_segment (source : str , node : AST , * , padded : bool = ...) -> Optional [ str ] : ...
267266
268267def walk (node : AST ) -> Iterator [AST ]: ...
269268
0 commit comments