diff --git a/jedi/api.py b/jedi/api.py index 0a62563b..2f854e09 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -328,8 +328,14 @@ class Script(object): TODO implement additional_module_paths """ + user_stmt = self.parser.user_stmt definitions, search_name = self._goto(add_import_name=True) - if not isinstance(self.parser.user_stmt, parsing.Import): + if isinstance(user_stmt, parsing.Statement) \ + and self.pos < user_stmt.get_assignment_calls().start_pos: + # the search_name might be before `=` + definitions = [v for v in user_stmt.set_vars + if str(v) == search_name] + if not isinstance(user_stmt, parsing.Import): # import case is looked at with add_import_name option definitions = dynamic.related_name_add_import_modules(definitions, search_name) diff --git a/jedi/evaluate.py b/jedi/evaluate.py index 449f8e29..078809fc 100644 --- a/jedi/evaluate.py +++ b/jedi/evaluate.py @@ -1373,9 +1373,9 @@ def follow_call_list(call_list): # comprehensions result += follow_statement(stmt) else: + # With things like params, these can also be functions... if isinstance(call, (Function, Class, Instance, dynamic.ArrayInstance)): - # With things like params, these can also be functions... result.append(call) # The string tokens are just operations (+, -, etc.) elif not isinstance(call, str): diff --git a/test/completion/renaming.py b/test/completion/renaming.py index 92e14a2f..5f9bacd7 100644 --- a/test/completion/renaming.py +++ b/test/completion/renaming.py @@ -90,8 +90,8 @@ from import_tree.rename1 import not_existing - - +response = 3 +#< 0 (95, 0), (96, 0), (97, 0), (99, 0) response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=%s.pdf' % id response.write(pdf)