diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 4838ff1a..08e9b7b0 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -266,7 +266,7 @@ class Script(object): stmt = r.module.statements[-1] except IndexError: raise NotFoundError() - if isinstance(stmt, pr.Flow): + if not isinstance(stmt, pr.Statement): raise NotFoundError() user_stmt = self._parser.user_stmt() diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index 151738ed..3b0c3363 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -96,6 +96,9 @@ def test_completion_on_complex_literals(): assert api.Script('4j').completions() == [] -def test_goto_assignments_on_for(): +def test_goto_assignments_on_non_statement(): with raises(api.NotFoundError): api.Script('for').goto_assignments() + + with raises(api.NotFoundError): + api.Script('assert').goto_assignments()