1
0
forked from VimPlug/jedi

Remove infer_state from filters

This commit is contained in:
Dave Halter
2019-08-16 09:41:23 +02:00
parent 600272366f
commit 9ee6285414
8 changed files with 13 additions and 21 deletions

View File

@@ -98,8 +98,7 @@ class AbstractUsedNamesFilter(AbstractFilter):
class ParserTreeFilter(AbstractUsedNamesFilter): class ParserTreeFilter(AbstractUsedNamesFilter):
# TODO remove infer_state as an argument, it's not used. def __init__(self, value, node_value=None, until_position=None,
def __init__(self, infer_state, value, node_value=None, until_position=None,
origin_scope=None): origin_scope=None):
""" """
node_value is an option to specify a second value for use cases node_value is an option to specify a second value for use cases
@@ -144,10 +143,9 @@ class ParserTreeFilter(AbstractUsedNamesFilter):
class FunctionExecutionFilter(ParserTreeFilter): class FunctionExecutionFilter(ParserTreeFilter):
param_name = ParamName 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): until_position=None, origin_scope=None):
super(FunctionExecutionFilter, self).__init__( super(FunctionExecutionFilter, self).__init__(
infer_state,
value, value,
node_value, node_value,
until_position, until_position,

View File

@@ -36,7 +36,6 @@ class StubModuleValue(ModuleValue):
def _get_stub_filters(self, search_global, **filter_kwargs): def _get_stub_filters(self, search_global, **filter_kwargs):
return [StubFilter( return [StubFilter(
self.infer_state,
value=self, value=self,
search_global=search_global, search_global=search_global,
**filter_kwargs **filter_kwargs

View File

@@ -58,7 +58,6 @@ class FunctionMixin(object):
def get_filters(self, search_global=False, until_position=None, origin_scope=None): def get_filters(self, search_global=False, until_position=None, origin_scope=None):
if search_global: if search_global:
yield ParserTreeFilter( yield ParserTreeFilter(
self.infer_state,
value=self, value=self,
until_position=until_position, until_position=until_position,
origin_scope=origin_scope origin_scope=origin_scope
@@ -294,7 +293,7 @@ class FunctionExecutionValue(TreeValue):
) )
def get_filters(self, search_global=False, until_position=None, origin_scope=None): 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, until_position=until_position,
origin_scope=origin_scope) origin_scope=origin_scope)

View File

@@ -132,7 +132,7 @@ class AbstractInstanceValue(Value):
# In this case we're excluding compiled objects that are # In this case we're excluding compiled objects that are
# not fake objects. It doesn't make sense for normal # not fake objects. It doesn't make sense for normal
# compiled objects to search for self variables. # 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( class_filters = class_value.get_filters(
search_global=False, search_global=False,
@@ -141,9 +141,9 @@ class AbstractInstanceValue(Value):
) )
for f in class_filters: for f in class_filters:
if isinstance(f, ClassFilter): if isinstance(f, ClassFilter):
yield InstanceClassFilter(self.infer_state, self, f) yield InstanceClassFilter(self, f)
elif isinstance(f, CompiledObjectFilter): elif isinstance(f, CompiledObjectFilter):
yield CompiledInstanceClassFilter(self.infer_state, self, f) yield CompiledInstanceClassFilter(self, f)
else: else:
# Propably from the metaclass. # Propably from the metaclass.
yield f yield f
@@ -348,8 +348,7 @@ class CompiledInstanceName(compiled.CompiledName):
class CompiledInstanceClassFilter(AbstractFilter): class CompiledInstanceClassFilter(AbstractFilter):
name_class = CompiledInstanceName name_class = CompiledInstanceName
def __init__(self, infer_state, instance, f): def __init__(self, instance, f):
self._infer_state = infer_state
self._instance = instance self._instance = instance
self._class_filter = f self._class_filter = f
@@ -362,7 +361,7 @@ class CompiledInstanceClassFilter(AbstractFilter):
def _convert(self, names): def _convert(self, names):
klass = self._class_filter.compiled_object klass = self._class_filter.compiled_object
return [ return [
CompiledInstanceName(self._infer_state, self._instance, klass, n) CompiledInstanceName(self._instance.infer_state, self._instance, klass, n)
for n in names for n in names
] ]
@@ -456,7 +455,7 @@ class InstanceClassFilter(AbstractFilter):
resulting names in LazyINstanceClassName. The idea is that the class name resulting names in LazyINstanceClassName. The idea is that the class name
filtering can be very flexible and always be reflected in instances. 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._instance = instance
self._class_filter = class_filter self._class_filter = class_filter
@@ -479,9 +478,8 @@ class SelfAttributeFilter(ClassFilter):
""" """
name_class = SelfName 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__( super(SelfAttributeFilter, self).__init__(
infer_state=infer_state,
value=value, value=value,
node_value=class_value, node_value=class_value,
origin_scope=origin_scope, origin_scope=origin_scope,

View File

@@ -117,7 +117,7 @@ class CompForValue(TreeValue):
return cls(parent_context.infer_state, parent_context, comp_for) return cls(parent_context.infer_state, parent_context, comp_for)
def get_filters(self, search_global=False, until_position=None, origin_scope=None): 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): def comprehension_from_atom(infer_state, value, atom):

View File

@@ -208,7 +208,7 @@ class ClassMixin(object):
yield filter yield filter
else: else:
yield ClassFilter( yield ClassFilter(
self.infer_state, self, node_value=cls, self, node_value=cls,
origin_scope=origin_scope, origin_scope=origin_scope,
is_instance=is_instance is_instance=is_instance
) )
@@ -230,7 +230,6 @@ class ClassMixin(object):
def get_global_filter(self, until_position=None, origin_scope=None): def get_global_filter(self, until_position=None, origin_scope=None):
return ParserTreeFilter( return ParserTreeFilter(
self.infer_state,
value=self, value=self,
until_position=until_position, until_position=until_position,
origin_scope=origin_scope origin_scope=origin_scope

View File

@@ -101,7 +101,6 @@ class ModuleMixin(SubModuleDictMixin):
def get_filters(self, search_global=False, until_position=None, origin_scope=None): def get_filters(self, search_global=False, until_position=None, origin_scope=None):
yield MergedFilter( yield MergedFilter(
ParserTreeFilter( ParserTreeFilter(
self.infer_state,
value=self, value=self,
until_position=until_position, until_position=until_position,
origin_scope=origin_scope origin_scope=origin_scope

View File

@@ -793,7 +793,7 @@ def get_metaclass_filters(func):
for metaclass in metaclasses: for metaclass in metaclasses:
if metaclass.py__name__() == 'EnumMeta' \ if metaclass.py__name__() == 'EnumMeta' \
and metaclass.get_root_value().py__name__() == 'enum': and metaclass.get_root_value().py__name__() == 'enum':
filter_ = ParserTreeFilter(cls.infer_state, value=cls) filter_ = ParserTreeFilter(value=cls)
return [DictFilter({ return [DictFilter({
name.string_name: EnumInstance(cls, name).name for name in filter_.values() name.string_name: EnumInstance(cls, name).name for name in filter_.values()
})] })]