diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 1739c129..ac2436ad 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -594,7 +594,7 @@ class Script(object): self._evaluator.eval_statement(stmt) analysis = [a for a in self._evaluator.analysis if self.path == a.path] - return sorted(analysis, key=lambda x: x.line) + return sorted(set(analysis), key=lambda x: x.line) class Interpreter(Script): diff --git a/jedi/evaluate/analysis.py b/jedi/evaluate/analysis.py index 42dd674e..965c892e 100644 --- a/jedi/evaluate/analysis.py +++ b/jedi/evaluate/analysis.py @@ -37,6 +37,16 @@ class Error(object): def __str__(self): return '%s: %s:%s' % (self.code, self.line, self.description()) + def __eq__(self, other): + return (self.path == other.path and self.name == other.name + and self._start_pos == other._start_pos) + + def __ne__(self, other): + return not self.__eq__(other) + + def __hash__(self): + return hash((self.path, self._start_pos, self.name)) + def __repr__(self): return '<%s %s: %s@%s,%s' % (self.__class__.__name__, self.name, self.path,