This file is nearly identical to fastparse.py
, except that it works with a Python 2
AST instead of a Python 3 AST.
Previously, how we handled Python 2 code was by first obtaining the Python 2 AST via typed_ast, converting it into a Python 3 AST by using typed_ast.conversion, then running it through mypy.fastparse.
While this worked, it did add some overhead, especially in larger Python 2 codebases. This module allows us to skip the conversion step, saving us some time.
The reason why this file is not easily merged with mypy.fastparse despite the large amount of redundancy is because the Python 2 AST and the Python 3 AST nodes belong to two completely different class hierarchies, which made it difficult to write a shared visitor between the two in a typesafe way.
Class | ASTConverter |
No class docstring; 0/7 instance variable, 0/2 constant, 1/73 method documented |
Function | is_no_type_check_decorator |
Undocumented |
Function | parse |
Parse a source file, without doing any semantic analysis. |
Constant | MISSING_FALLBACK |
Undocumented |
Constant | N |
Undocumented |
Constant | TYPE_COMMENT_AST_ERROR |
Undocumented |
Constant | TYPE_COMMENT_SYNTAX_ERROR |
Undocumented |
Constant | _dummy_fallback |
Undocumented |
Parse a source file, without doing any semantic analysis.
Return the parse tree. If errors is not provided, raise ParseError on failure. Otherwise, use the errors object to report parse errors.
Parameters | |
source:Union[ | Undocumented |
fnam:str | Undocumented |
module:Optional[ | Undocumented |
errors:Optional[ | Undocumented |
options:Optional[ | Undocumented |
Returns | |
MypyFile | Undocumented |