mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Ignore warnings for numpydocs
This commit is contained in:
@@ -16,6 +16,7 @@ annotations.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import warnings
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
from parso import parse, ParserSyntaxError
|
from parso import parse, ParserSyntaxError
|
||||||
@@ -60,12 +61,14 @@ def _get_numpy_doc_string_cls():
|
|||||||
|
|
||||||
def _search_param_in_numpydocstr(docstr, param_str):
|
def _search_param_in_numpydocstr(docstr, param_str):
|
||||||
"""Search `docstr` (in numpydoc format) for type(-s) of `param_str`."""
|
"""Search `docstr` (in numpydoc format) for type(-s) of `param_str`."""
|
||||||
try:
|
with warnings.catch_warnings():
|
||||||
# This is a non-public API. If it ever changes we should be
|
warnings.simplefilter("ignore")
|
||||||
# prepared and return gracefully.
|
try:
|
||||||
params = _get_numpy_doc_string_cls()(docstr)._parsed_data['Parameters']
|
# This is a non-public API. If it ever changes we should be
|
||||||
except Exception:
|
# prepared and return gracefully.
|
||||||
return []
|
params = _get_numpy_doc_string_cls()(docstr)._parsed_data['Parameters']
|
||||||
|
except Exception:
|
||||||
|
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:
|
||||||
m = re.match(r'([^,]+(,[^,]+)*?)(,[ ]*optional)?$', p_type)
|
m = re.match(r'([^,]+(,[^,]+)*?)(,[ ]*optional)?$', p_type)
|
||||||
@@ -79,10 +82,12 @@ def _search_return_in_numpydocstr(docstr):
|
|||||||
"""
|
"""
|
||||||
Search `docstr` (in numpydoc format) for type(-s) of function returns.
|
Search `docstr` (in numpydoc format) for type(-s) of function returns.
|
||||||
"""
|
"""
|
||||||
try:
|
with warnings.catch_warnings():
|
||||||
doc = _get_numpy_doc_string_cls()(docstr)
|
warnings.simplefilter("ignore")
|
||||||
except Exception:
|
try:
|
||||||
return
|
doc = _get_numpy_doc_string_cls()(docstr)
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
# 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user