Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode python refactor failed

When I tried to rename myset in the following code, I saw the following message.

class NumberGenerator:
    def __init__(self):
        self.__myset__ = set()

    def uncount(self, i):
        self.__myset__.add(i)

Refactor failed. module 'rope.base.ast' has no attribute 'Str'
[<FrameSummary file refactor.py, line 294 in watch>, <FrameSummary file refactor.py, line 274 in _process_request>, <FrameSummary file refactor.py, line 206 in _rename>, ...

It's so long, if you want to see I can show you. Is this code wrong? It works, though. Why does refactor not work?

like image 588
Hyonyoung Park Avatar asked Dec 28 '19 07:12

Hyonyoung Park


People also ask

Why is Vscode refactoring not available?

The reason you're seeing "No refactorings available" is because the currently selected text doesn't match any of these actions. Try selecting a line of text and then press [Ctrl][Shift][R] .

Can you refactor in VS code?

Visual Studio Code supports refactoring operations (refactorings) such as Extract Method and Extract Variable to improve your code base from within your editor.

How do I enable refactor in Visual Studio?

Visit the Tools-Options page, IntelliCode General tab, Preview features area, and switch C# refactorings to “Enabled” to turn it on.


1 Answers

It doesn't work because Rope has some bugs in it. If you install Pylance then you may have better success (it will automatically prompt you to update your settings appropriately).

like image 104
Brett Cannon Avatar answered Oct 18 '22 01:10

Brett Cannon