vscode python重构失败

时间:2019-12-28 07:29:28

标签: python visual-studio-code

当我尝试在以下代码中重命名 myset 时,我看到了以下消息。

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>, ...

太长了,如果你想看的话,我会全部展示。 此代码是否错误? 但这有效。 为什么重构不起作用?

1 个答案:

答案 0 :(得分:16)

它不起作用,因为Rope中有一些错误。如果使用设置 class MainActivity : AppCompatActivity() { // lateinit var listNotes: ArrayList<Notes> var listNotes: ArrayList<Notes>() //<=====HERE!!! override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) //Add dummy data listNotes.add(Notes(1,"meet Profesor","asdasdasd asdads asdad asdasd asdasd asdasd")) listNotes.add(Notes(2,"eat something","asdasddfdfdf;l;l;l;l;l;laspopopopo popo popo d asdasd")) listNotes.add(Notes(3,"go to the movies","ann nunun nun nun ijijok koko kok okok ok nununun")) var myNotesAdapter= myNotesAdapter(listNotes) lvNotes.adapter= myNotesAdapter } //....more code } 切换到Microsoft Python Language Server,则可能会获得更好的成功。