forked from VimPlug/jedi
Fix _get_numpy_doc_string_cls: use cache
I've noticed that Jedi tries to import numpydoc a lot when using jedi-vim's goto method in jedi_vim.py itself (via printing in Neovim's VimPathFinder.find_spec). This patch uses the cache before trying the import again and again.
This commit is contained in:
committed by
Dave Halter
parent
fc14aad8f2
commit
6748faa071
@@ -47,13 +47,14 @@ _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):
|
||||||
|
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 as e:
|
||||||
_numpy_doc_string_cache = e
|
_numpy_doc_string_cache = e
|
||||||
if isinstance(_numpy_doc_string_cache, ImportError):
|
raise
|
||||||
raise _numpy_doc_string_cache
|
|
||||||
return _numpy_doc_string_cache
|
return _numpy_doc_string_cache
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user