module documentation
(source)

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
def is_no_type_check_decorator(expr): (source)

Undocumented

Parameters
expr:ast27.exprUndocumented
Returns
boolUndocumented
def parse(source, fnam, module, errors=None, options=None): (source)

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[str, bytes]Undocumented
fnam:strUndocumented
module:Optional[str]Undocumented
errors:Optional[Errors]Undocumented
options:Optional[Options]Undocumented
Returns
MypyFileUndocumented
MISSING_FALLBACK = (source)

Undocumented

Value
FakeInfo('fallback can\'t be filled out until semanal')

Undocumented

Value
TypeVar('N',
        bound=Node)
TYPE_COMMENT_AST_ERROR: str = (source)

Undocumented

Value
'invalid type comment'
TYPE_COMMENT_SYNTAX_ERROR: str = (source)

Undocumented

Value
'syntax error in type comment'
_dummy_fallback = (source)

Undocumented

Value
Instance(MISSING_FALLBACK, [], -1)