mirror of
https://github.com/davidhalter/jedi.git
synced 2026-03-02 01:16:51 +08:00
Name lookups shouldn't return duplicates.
This commit is contained in:
@@ -332,7 +332,7 @@ class Script(object):
|
|||||||
:rtype: list of :class:`classes.Definition`
|
:rtype: list of :class:`classes.Definition`
|
||||||
"""
|
"""
|
||||||
def resolve_import_paths(scopes):
|
def resolve_import_paths(scopes):
|
||||||
for s in scopes.copy():
|
for s in set(scopes):
|
||||||
if isinstance(s, imports.ImportWrapper):
|
if isinstance(s, imports.ImportWrapper):
|
||||||
scopes.remove(s)
|
scopes.remove(s)
|
||||||
scopes.update(resolve_import_paths(set(s.follow())))
|
scopes.update(resolve_import_paths(set(s.follow())))
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ class NameFinder(object):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _names_to_types(self, names, search_global):
|
def _names_to_types(self, names, search_global):
|
||||||
types = []
|
types = set()
|
||||||
|
|
||||||
# Add isinstance and other if/assert knowledge.
|
# Add isinstance and other if/assert knowledge.
|
||||||
if isinstance(self.name_str, tree.Name):
|
if isinstance(self.name_str, tree.Name):
|
||||||
@@ -268,12 +268,12 @@ class NameFinder(object):
|
|||||||
for name in names:
|
for name in names:
|
||||||
new_types = _name_to_types(self._evaluator, name, self.scope)
|
new_types = _name_to_types(self._evaluator, name, self.scope)
|
||||||
if isinstance(self.scope, (er.Class, er.Instance)) and not search_global:
|
if isinstance(self.scope, (er.Class, er.Instance)) and not search_global:
|
||||||
types += self._resolve_descriptors(name, new_types)
|
types |= set(self._resolve_descriptors(name, new_types))
|
||||||
else:
|
else:
|
||||||
types += new_types
|
types |= set(new_types)
|
||||||
if not names and isinstance(self.scope, er.Instance):
|
if not names and isinstance(self.scope, er.Instance):
|
||||||
# handling __getattr__ / __getattribute__
|
# handling __getattr__ / __getattribute__
|
||||||
types = self._check_getattr(self.scope)
|
return self._check_getattr(self.scope)
|
||||||
|
|
||||||
return types
|
return types
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user