forked from VimPlug/jedi
Remove infer_state from filters
This commit is contained in:
@@ -98,8 +98,7 @@ class AbstractUsedNamesFilter(AbstractFilter):
|
||||
|
||||
|
||||
class ParserTreeFilter(AbstractUsedNamesFilter):
|
||||
# TODO remove infer_state as an argument, it's not used.
|
||||
def __init__(self, infer_state, value, node_value=None, until_position=None,
|
||||
def __init__(self, value, node_value=None, until_position=None,
|
||||
origin_scope=None):
|
||||
"""
|
||||
node_value is an option to specify a second value for use cases
|
||||
@@ -144,10 +143,9 @@ class ParserTreeFilter(AbstractUsedNamesFilter):
|
||||
class FunctionExecutionFilter(ParserTreeFilter):
|
||||
param_name = ParamName
|
||||
|
||||
def __init__(self, infer_state, value, node_value=None,
|
||||
def __init__(self, value, node_value=None,
|
||||
until_position=None, origin_scope=None):
|
||||
super(FunctionExecutionFilter, self).__init__(
|
||||
infer_state,
|
||||
value,
|
||||
node_value,
|
||||
until_position,
|
||||
|
||||
@@ -36,7 +36,6 @@ class StubModuleValue(ModuleValue):
|
||||
|
||||
def _get_stub_filters(self, search_global, **filter_kwargs):
|
||||
return [StubFilter(
|
||||
self.infer_state,
|
||||
value=self,
|
||||
search_global=search_global,
|
||||
**filter_kwargs
|
||||
|
||||
@@ -58,7 +58,6 @@ class FunctionMixin(object):
|
||||
def get_filters(self, search_global=False, until_position=None, origin_scope=None):
|
||||
if search_global:
|
||||
yield ParserTreeFilter(
|
||||
self.infer_state,
|
||||
value=self,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope
|
||||
@@ -294,7 +293,7 @@ class FunctionExecutionValue(TreeValue):
|
||||
)
|
||||
|
||||
def get_filters(self, search_global=False, until_position=None, origin_scope=None):
|
||||
yield self.function_execution_filter(self.infer_state, self,
|
||||
yield self.function_execution_filter(self,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope)
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class AbstractInstanceValue(Value):
|
||||
# In this case we're excluding compiled objects that are
|
||||
# not fake objects. It doesn't make sense for normal
|
||||
# compiled objects to search for self variables.
|
||||
yield SelfAttributeFilter(self.infer_state, self, cls, origin_scope)
|
||||
yield SelfAttributeFilter(self, cls, origin_scope)
|
||||
|
||||
class_filters = class_value.get_filters(
|
||||
search_global=False,
|
||||
@@ -141,9 +141,9 @@ class AbstractInstanceValue(Value):
|
||||
)
|
||||
for f in class_filters:
|
||||
if isinstance(f, ClassFilter):
|
||||
yield InstanceClassFilter(self.infer_state, self, f)
|
||||
yield InstanceClassFilter(self, f)
|
||||
elif isinstance(f, CompiledObjectFilter):
|
||||
yield CompiledInstanceClassFilter(self.infer_state, self, f)
|
||||
yield CompiledInstanceClassFilter(self, f)
|
||||
else:
|
||||
# Propably from the metaclass.
|
||||
yield f
|
||||
@@ -348,8 +348,7 @@ class CompiledInstanceName(compiled.CompiledName):
|
||||
class CompiledInstanceClassFilter(AbstractFilter):
|
||||
name_class = CompiledInstanceName
|
||||
|
||||
def __init__(self, infer_state, instance, f):
|
||||
self._infer_state = infer_state
|
||||
def __init__(self, instance, f):
|
||||
self._instance = instance
|
||||
self._class_filter = f
|
||||
|
||||
@@ -362,7 +361,7 @@ class CompiledInstanceClassFilter(AbstractFilter):
|
||||
def _convert(self, names):
|
||||
klass = self._class_filter.compiled_object
|
||||
return [
|
||||
CompiledInstanceName(self._infer_state, self._instance, klass, n)
|
||||
CompiledInstanceName(self._instance.infer_state, self._instance, klass, n)
|
||||
for n in names
|
||||
]
|
||||
|
||||
@@ -456,7 +455,7 @@ class InstanceClassFilter(AbstractFilter):
|
||||
resulting names in LazyINstanceClassName. The idea is that the class name
|
||||
filtering can be very flexible and always be reflected in instances.
|
||||
"""
|
||||
def __init__(self, infer_state, instance, class_filter):
|
||||
def __init__(self, instance, class_filter):
|
||||
self._instance = instance
|
||||
self._class_filter = class_filter
|
||||
|
||||
@@ -479,9 +478,8 @@ class SelfAttributeFilter(ClassFilter):
|
||||
"""
|
||||
name_class = SelfName
|
||||
|
||||
def __init__(self, infer_state, value, class_value, origin_scope):
|
||||
def __init__(self, value, class_value, origin_scope):
|
||||
super(SelfAttributeFilter, self).__init__(
|
||||
infer_state=infer_state,
|
||||
value=value,
|
||||
node_value=class_value,
|
||||
origin_scope=origin_scope,
|
||||
|
||||
@@ -117,7 +117,7 @@ class CompForValue(TreeValue):
|
||||
return cls(parent_context.infer_state, parent_context, comp_for)
|
||||
|
||||
def get_filters(self, search_global=False, until_position=None, origin_scope=None):
|
||||
yield ParserTreeFilter(self.infer_state, self)
|
||||
yield ParserTreeFilter(self)
|
||||
|
||||
|
||||
def comprehension_from_atom(infer_state, value, atom):
|
||||
|
||||
@@ -208,7 +208,7 @@ class ClassMixin(object):
|
||||
yield filter
|
||||
else:
|
||||
yield ClassFilter(
|
||||
self.infer_state, self, node_value=cls,
|
||||
self, node_value=cls,
|
||||
origin_scope=origin_scope,
|
||||
is_instance=is_instance
|
||||
)
|
||||
@@ -230,7 +230,6 @@ class ClassMixin(object):
|
||||
|
||||
def get_global_filter(self, until_position=None, origin_scope=None):
|
||||
return ParserTreeFilter(
|
||||
self.infer_state,
|
||||
value=self,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope
|
||||
|
||||
@@ -101,7 +101,6 @@ class ModuleMixin(SubModuleDictMixin):
|
||||
def get_filters(self, search_global=False, until_position=None, origin_scope=None):
|
||||
yield MergedFilter(
|
||||
ParserTreeFilter(
|
||||
self.infer_state,
|
||||
value=self,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope
|
||||
|
||||
@@ -793,7 +793,7 @@ def get_metaclass_filters(func):
|
||||
for metaclass in metaclasses:
|
||||
if metaclass.py__name__() == 'EnumMeta' \
|
||||
and metaclass.get_root_value().py__name__() == 'enum':
|
||||
filter_ = ParserTreeFilter(cls.infer_state, value=cls)
|
||||
filter_ = ParserTreeFilter(value=cls)
|
||||
return [DictFilter({
|
||||
name.string_name: EnumInstance(cls, name).name for name in filter_.values()
|
||||
})]
|
||||
|
||||
Reference in New Issue
Block a user