Fix some small things to get more tests passing

This commit is contained in:
Dave Halter
2019-07-01 21:52:03 -07:00
parent b382f06be0
commit 3829ef4785
3 changed files with 5 additions and 4 deletions

View File

@@ -504,7 +504,7 @@ class SelfAttributeFilter(ClassFilter):
if trailer.type == 'trailer' \ if trailer.type == 'trailer' \
and len(trailer.parent.children) == 2 \ and len(trailer.parent.children) == 2 \
and trailer.children[0] == '.': and trailer.children[0] == '.':
if name.is_definition() and self._access_possible(name): if name.is_definition() and self._access_possible(name, from_instance=True):
# TODO filter non-self assignments. # TODO filter non-self assignments.
yield name yield name

View File

@@ -109,7 +109,7 @@ class ClassFilter(ParserTreeFilter):
node = get_cached_parent_scope(self._used_names, node) node = get_cached_parent_scope(self._used_names, node)
return False return False
def _access_possible(self, name, from_instance): def _access_possible(self, name, from_instance=False):
# Filter for ClassVar variables # Filter for ClassVar variables
# TODO this is not properly done, yet. It just checks for the string # TODO this is not properly done, yet. It just checks for the string
# ClassVar in the annotation, which can be quite imprecise. If we # ClassVar in the annotation, which can be quite imprecise. If we
@@ -212,6 +212,7 @@ class ClassMixin(object):
if not is_instance: if not is_instance:
from jedi.evaluate.compiled import builtin_from_name from jedi.evaluate.compiled import builtin_from_name
type_ = builtin_from_name(self.evaluator, u'type') type_ = builtin_from_name(self.evaluator, u'type')
assert isinstance(type_, ClassContext)
if type_ != self: if type_ != self:
yield next(type_.get_filters()) yield next(type_.get_filters())

View File

@@ -77,7 +77,7 @@ class AbstractUsedNamesFilter(AbstractFilter):
def get(self, name, **filter_kwargs): def get(self, name, **filter_kwargs):
return self._convert_names(self._filter( return self._convert_names(self._filter(
_get_definition_names(self._used_names, name), _get_definition_names(self._used_names, name),
**filter_kwargs, **filter_kwargs
)) ))
def _convert_names(self, names): def _convert_names(self, names):
@@ -89,7 +89,7 @@ class AbstractUsedNamesFilter(AbstractFilter):
for name_key in self._used_names for name_key in self._used_names
for name in self._filter( for name in self._filter(
_get_definition_names(self._used_names, name_key), _get_definition_names(self._used_names, name_key),
**filter_kwargs, **filter_kwargs
) )
) )