Skip to content

Commit 6812993

Browse files
committed
store cache as dict
1 parent f99d33e commit 6812993

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pyls/plugins/importmagic_lint.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
UNRES_RE = re.compile(r"Unresolved import '(?P<unresolved>[\w.]+)'")
1717
UNREF_RE = re.compile(r"Unreferenced import '(?P<unreferenced>[\w.]+)'")
1818

19-
_index_cache = None
19+
_index_cache = {}
2020

2121

2222
def _build_index(paths):
@@ -30,23 +30,23 @@ def _build_index(paths):
3030

3131

3232
def _cache_index_callback(future):
33-
global _index_cache
3433
# Cache the index
35-
_index_cache = future.result()
34+
_index_cache['default'] = future.result()
3635

3736

3837
def _get_index():
3938
"""Get the cached index if built and index project files on each call.
4039
Return an empty index if not built yet.
4140
"""
4241
# Index haven't been built yet
43-
if _index_cache is None:
42+
index = _index_cache.get('default')
43+
if index is None:
4444
return importmagic.SymbolIndex()
4545

4646
# Index project files
4747
# TODO(youben) index project files
48-
#index.build_index(paths=[])
49-
return _index_cache
48+
# index.build_index(paths=[])
49+
return _index_cache['default']
5050

5151

5252
def _get_imports_list(source, index=None):

test/plugins/test_importmagic_lint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_importmagic_actions(config):
4242
try:
4343
importmagic_lint.pyls_initialize()
4444
name, doc = temp_document(DOC)
45-
while importmagic_lint._index_cache is None:
45+
while importmagic_lint._index_cache.get('default') is None:
4646
# wait for the index to be ready
4747
sleep(1)
4848
actions = importmagic_lint.pyls_code_actions(config, doc)

0 commit comments

Comments
 (0)