Skip to content

Commit

Permalink
Fix inline case where a name was removed without the code being used, f…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed May 14, 2020
1 parent 381fbed commit d4aa583
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jedi/api/refactoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def inline(inference_state, names):
raise RefactoringError("No definition found to inline")
if len(definitions) > 1:
raise RefactoringError("Cannot inline a name with multiple definitions")
if len(names) == 1:
raise RefactoringError("There are no references to this name")

tree_name = definitions[0].tree_name

Expand Down
5 changes: 5 additions & 0 deletions test/refactor/inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
1
# ++++++++++++++++++++++++++++++++++++++++++++++++++
There is no name under the cursor
# -------------------------------------------------- no-reference-error
#? 0 error
a = 1
# ++++++++++++++++++++++++++++++++++++++++++++++++++
There are no references to this name
# -------------------------------------------------- multi-equal-error
def test():
#? 4 error
Expand Down

0 comments on commit d4aa583

Please sign in to comment.