VSCode Python项目重命名符号未同步到测试文件的问题咨询
VSCode Python重命名符号无法同步到测试文件
在Python项目中使用VSCode的**重命名符号(rename symbol)**功能时,符号名称的变更无法同步到测试文件:位于test目录下或命名为test_*.py的.py文件不会更新符号名称。非测试文件(如something_else.py)能正常反映重构后的名称,但test_thing.py这类测试文件完全不受影响。
项目文件结构
my_project/ test/ __init__.py test_thing.py __init__.py thing.py something_else.py
相关代码示例
thing.py
class Thing: ...
test_thing.py
from my_project.thing import Thing
当前VSCode配置(settings.json)
{ "[python]": { "editor.codeActionsOnSave": { "source.fixAll": "explicit" }, "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true, "editor.formatOnType": true }, "[toml]": { "editor.formatOnSave": false }, "cSpell.enabled": false, "cSpell.userWords": [ "callstack", "dataframes", "docstrings", "kwargs", "Numpy", ], "editor.formatOnPaste": true, "editor.formatOnSave": true, "editor.formatOnType": true, "editor.inlineSuggest.enabled": true, "editor.minimap.enabled": false, "editor.rulers": [ 88, 120 ], "evenBetterToml.formatter.alignComments": false, "evenBetterToml.formatter.arrayTrailingComma": true, "evenBetterToml.formatter.compactEntries": false, "explorer.confirmDragAndDrop": false, "files.insertFinalNewline": true, "git.autofetch": true, "github.copilot.enable": { "*": true, "markdown": true, "plaintext": true, "scminput": false }, "jupyter.askForKernelRestart": false, "python.analysis.autoFormatStrings": true, "python.analysis.autoImportCompletions": true, "python.languageServer": "Pylance", "python.venvFolders": [ "~/.mambaforge/envs" ], "terminal.integrated.inheritEnv": false, "terminal.integrated.scrollback": 3000, "window.nativeTabs": true }
疑问
如何让VSCode将重命名的符号同步到测试文件中?是否存在未注意到的设置项,或是VSCode Python扩展的bug?
内容的提问来源于stack exchange,提问作者rmorshea
相关产品推荐
相关产品推荐

