forked from VimPlug/jedi
Deal with SyntaxErrors coming from numpydoc when used with Python 2
This commit is contained in:
@@ -48,13 +48,12 @@ _numpy_doc_string_cache = None
|
|||||||
|
|
||||||
def _get_numpy_doc_string_cls():
|
def _get_numpy_doc_string_cls():
|
||||||
global _numpy_doc_string_cache
|
global _numpy_doc_string_cache
|
||||||
if isinstance(_numpy_doc_string_cache, ImportError):
|
if isinstance(_numpy_doc_string_cache, (ImportError, SyntaxError)):
|
||||||
raise _numpy_doc_string_cache
|
raise _numpy_doc_string_cache
|
||||||
try:
|
try:
|
||||||
from numpydoc.docscrape import NumpyDocString
|
from numpydoc.docscrape import NumpyDocString
|
||||||
_numpy_doc_string_cache = NumpyDocString
|
_numpy_doc_string_cache = NumpyDocString
|
||||||
except ImportError as e:
|
except (ImportError, SyntaxError) as e:
|
||||||
_numpy_doc_string_cache = e
|
|
||||||
raise
|
raise
|
||||||
return _numpy_doc_string_cache
|
return _numpy_doc_string_cache
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ def _search_param_in_numpydocstr(docstr, param_str):
|
|||||||
# This is a non-public API. If it ever changes we should be
|
# This is a non-public API. If it ever changes we should be
|
||||||
# prepared and return gracefully.
|
# prepared and return gracefully.
|
||||||
params = _get_numpy_doc_string_cls()(docstr)._parsed_data['Parameters']
|
params = _get_numpy_doc_string_cls()(docstr)._parsed_data['Parameters']
|
||||||
except (KeyError, AttributeError, ImportError):
|
except (KeyError, AttributeError, ImportError, SyntaxError):
|
||||||
return []
|
return []
|
||||||
for p_name, p_type, p_descr in params:
|
for p_name, p_type, p_descr in params:
|
||||||
if p_name == param_str:
|
if p_name == param_str:
|
||||||
|
|||||||
Reference in New Issue
Block a user