diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2019-02-27 10:22:17 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-02-27 10:22:17 +0100 |
| commit | 9eddca32cde1fb5699dddc7eea76a7cce4d31719 (patch) | |
| tree | 4db445907ca522e9e830f6bad8eed49973c04fc1 | |
| parent | 87db3f5d1b1b6713d12e1ee83fd7c1f7db7059b6 (diff) | |
| download | astroid-git-9eddca32cde1fb5699dddc7eea76a7cce4d31719.tar.gz | |
When picking the parse function, make sure to parse with the right minor versionastroid-2.2.0
Until now we were parsing with the default 3.6 with typed_ast, which does not
make sense for Python 3.5 and 3.4
| -rw-r--r-- | astroid/_ast.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/astroid/_ast.py b/astroid/_ast.py index f6858ae0..da95f1de 100644 --- a/astroid/_ast.py +++ b/astroid/_ast.py @@ -1,6 +1,8 @@ import ast from collections import namedtuple +from functools import partial from typing import Optional +import sys _ast_py2 = _ast_py3 = None try: @@ -22,7 +24,11 @@ def _get_parser_module(parse_python_two: bool = False): def _parse(string: str, parse_python_two: bool = False): - return _get_parser_module(parse_python_two=parse_python_two).parse(string) + parse_module = _get_parser_module(parse_python_two=parse_python_two) + parse_func = parse_module.parse + if _ast_py3 and not parse_python_two: + parse_func = partial(parse_func, feature_version=sys.version_info.minor) + return parse_func(string) def parse_function_type_comment(type_comment: str) -> Optional[FunctionType]: |
