-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for type comments (#548)
- Loading branch information
1 parent
5d17f5b
commit 2c655de
Showing
8 changed files
with
270 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ast | ||
|
||
_ast_py2 = _ast_py3 = None | ||
try: | ||
import typed_ast.ast3 as _ast_py3 | ||
import typed_ast.ast27 as _ast_py2 | ||
except ImportError: | ||
pass | ||
|
||
|
||
def _get_parser_module(parse_python_two: bool = False): | ||
if parse_python_two: | ||
parser_module = _ast_py2 | ||
else: | ||
parser_module = _ast_py3 | ||
return parser_module or ast | ||
|
||
|
||
def _parse(string: str, | ||
parse_python_two: bool = False): | ||
return _get_parser_module(parse_python_two=parse_python_two).parse(string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.