mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix some small things to get more tests passing
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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())
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user