forked from VimPlug/jedi
context -> value
This commit is contained in:
@@ -1 +1 @@
|
||||
from jedi.common.context import BaseContextSet, BaseContext
|
||||
from jedi.common.value import BaseContextSet, BaseContext
|
||||
|
||||
@@ -16,7 +16,7 @@ def traverse_parents(path, include_current=False):
|
||||
@contextmanager
|
||||
def monkeypatch(obj, attribute_name, new_value):
|
||||
"""
|
||||
Like pytest's monkeypatch, but as a context manager.
|
||||
Like pytest's monkeypatch, but as a value manager.
|
||||
"""
|
||||
old_value = getattr(obj, attribute_name)
|
||||
try:
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
class BaseContext(object):
|
||||
def __init__(self, infer_state, parent_context=None):
|
||||
def __init__(self, infer_state, parent_value=None):
|
||||
self.infer_state = infer_state
|
||||
self.parent_context = parent_context
|
||||
self.parent_value = parent_value
|
||||
|
||||
def get_root_context(self):
|
||||
context = self
|
||||
def get_root_value(self):
|
||||
value = self
|
||||
while True:
|
||||
if context.parent_context is None:
|
||||
return context
|
||||
context = context.parent_context
|
||||
if value.parent_value is None:
|
||||
return value
|
||||
value = value.parent_value
|
||||
|
||||
|
||||
class BaseContextSet(object):
|
||||
def __init__(self, iterable):
|
||||
self._set = frozenset(iterable)
|
||||
for context in iterable:
|
||||
assert not isinstance(context, BaseContextSet)
|
||||
for value in iterable:
|
||||
assert not isinstance(value, BaseContextSet)
|
||||
|
||||
@classmethod
|
||||
def _from_frozen_set(cls, frozenset_):
|
||||
@@ -61,8 +61,8 @@ class BaseContextSet(object):
|
||||
def __getattr__(self, name):
|
||||
def mapper(*args, **kwargs):
|
||||
return self.from_sets(
|
||||
getattr(context, name)(*args, **kwargs)
|
||||
for context in self._set
|
||||
getattr(value, name)(*args, **kwargs)
|
||||
for value in self._set
|
||||
)
|
||||
return mapper
|
||||
|
||||
Reference in New Issue
Block a user