From c2a287c25a7c272daf5811c663a57401a29caeaa Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 28 Apr 2015 17:35:26 +0200 Subject: [PATCH] Usages on syntax should not return anything. --- jedi/api/__init__.py | 6 +++++- test/completion/usages.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index a8a7c288..a5b0b109 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -466,7 +466,11 @@ class Script(object): # For not defined imports (goto doesn't find something, we take # the name as a definition. This is enough, because every name # points to it. - definitions = [user_stmt.name_for_position(self._pos)] + name = user_stmt.name_for_position(self._pos) + if name is None: + # Must be syntax + return [] + definitions = [name] if not definitions: # Without a definition for a name we cannot find references. diff --git a/test/completion/usages.py b/test/completion/usages.py index cc51326a..c5688f77 100644 --- a/test/completion/usages.py +++ b/test/completion/usages.py @@ -266,3 +266,10 @@ import _sre #< 0 (-3,7), (0,0), ('_sre', None, None) _sre + +# ----------------- +# on syntax +# ----------------- + +#< 0 +import undefined