我遇到了这个重构问题,我试图通过“重命名符号”选项来重命名一个函数,但这将花费很长时间。有一个“进度条”无休止地在文档选项卡下面移动。重命名(也使用变量名)大约需要5分钟。
这是正常的行为吗?我在同一个文件夹中有大约10个大约100行的python文件。但是,我有一个数据文件夹(属于项目),里面有大约100,000个txt文件( git,btw忽略了)。这些文件也被考虑到了吗?有没有办法只在当前文件中重命名?
VS代码版本: 1.25.0 Python扩展: 2018.6.0
谢谢,拉法
发布于 2019-01-12 20:03:38
这里也有同样的问题,这显然是由于Rope库(用于进行重构)不完全支持Python3。
这里有一期描述类似问题的人-- https://github.com/Microsoft/vscode-python/issues/52
更新:使用Jedi代替Microsoft Python Language Server for intellisense似乎已经为我解决了这个问题。只需将以下条目添加到您的settings.json文件中:
"python.jediEnabled": true发布于 2021-08-27 04:41:48
摘要
我发现rope没有忽略我的虚拟环境中的文件,这些文件位于我的工作空间目录中。这造成了可以理解的缓慢的重构性能。我将虚拟环境文件夹添加到rope配置文件config.py中的ignored_resources中。在进行更改后,重构性能立即得到了极大的提高。
示例
请看下面的文件夹结构。
-.venv
-.vscode
--.ropeproject
---config.py
---objectdb
--pythonpackage
---__init__.py
---[other files I want to refactor]
-main.py假设.venv是您的虚拟环境的名称,为了让rope忽略它,您需要在rope config.py文件的ignored_resources列表中包含.venv。示例如下所示。
def set_prefs(prefs):
"""This function is called before opening the project"""
# Specify which files and folders to ignore in the project.
# Changes to ignored resources are not added to the history and
# VCSs. Also they are not returned in `Project.get_files()`.
# Note that ``?`` and ``*`` match all characters but slashes.
# '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
# 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
# '.svn': matches 'pkg/.svn' and all of its children
# 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
# 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
'.hg', '.svn', '_svn', '.git', '.tox', '.venv']https://stackoverflow.com/questions/51235056
复制相似问题