diff --git a/jedi/api.py b/jedi/api.py index 593d6996..bd91d7a7 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -340,7 +340,7 @@ class Script(object): else: names.append(dynamic.RelatedName(d.names[0], d)) - return sorted(names, key=lambda x: (x.module_path, x.start_pos)) + return sorted(set(names), key=lambda x: (x.module_path, x.start_pos)) def get_in_function_call(self): """ diff --git a/jedi/dynamic.py b/jedi/dynamic.py index 9c26e2a4..5bdfaf6a 100644 --- a/jedi/dynamic.py +++ b/jedi/dynamic.py @@ -449,3 +449,10 @@ class RelatedName(BaseOutput): @property def description(self): return "%s@%s,%s" % (self.text, self.start_pos[0], self.start_pos[1]) + + def __eq__(self, other): + return self.start_pos == other.start_pos \ + and self.module_path == other.module_path + + def __hash__(self): + return hash((self.start_pos, self.module_path)) diff --git a/test/completion/renaming.py b/test/completion/renaming.py index 23c6405f..f860077f 100644 --- a/test/completion/renaming.py +++ b/test/completion/renaming.py @@ -71,10 +71,10 @@ module_not_exists -#< (85,17), (75,24), (78,0), (81,17), (4,5) +#< (1,0), (85,17), (75,24), (78,0), (81,17), (4,5) from import_tree import rename1 -#< (78,8), (3,0), (4,20), (6,0), (81,32), (82,0), (6,0) +#< (78,8), (3,0), (4,20), (6,0), (81,32), (82,0) rename1.abc #< (78,8), (3,0), (4,20), (6,0), (81,32), (82,0)