【问题标题】:VSCode Python Intellisense Not Working ProperlyVSCode Python Intellisense 无法正常工作
【发布时间】:2021-09-01 18:36:07
【问题描述】:

VSCode 中的 Python 自动完成功能弄乱了我的代码

这是我的系统:

如果我使用Pylance,Intellisense 无法正常工作

如果我使用Jedi,Intellisense 无法正常工作

当我按下回车键时,我的代码完全失效了。这只是一个例子,让我很沮丧!

下面是我的settings.json文件:

{
    "AREPL.pythonPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
    "dicom.alwaysShowMenu": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true
    },
    "editor.formatOnSave": true,
    "editor.insertSpaces": false,
    "editor.rulers": [
        90
    ],
    "editor.suggestSelection": "first",
    "explorer.compactFolders": false,
    "explorer.confirmDragAndDrop": false,
    "files.exclude": {
        "**/.git": false
    },
    "files.trimFinalNewlines": true,
    "files.trimTrailingWhitespace": true,
    "git-graph.defaultColumnVisibility": {
        "Author": false,
        "Commit": true,
        "Date": false
    },
    "git-graph.referenceLabels.alignment": "Branches (aligned to the graph) & Tags (on the right)",
    "glassit.alpha": 255,
    "json.format.enable": true,
    "mypy.dmypyExecutable": "${workspaceFolder}\\.venv\\Scripts\\dmypy.exe",
    "mypy.runUsingActiveInterpreter": true,
    "notebook.cellToolbarLocation": {
        "default": "right",
        "jupyter-notebook": "left"
    },
    "python.defaultInterpreterPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
    "python.formatting.blackArgs": [
        "--line-length",
        "90"
    ],
    "python.formatting.provider": "black",
    "python.languageServer": "Jedi",
    "python.linting.enabled": true,
    // "python.linting.flake8Args": [
    //     "--line-length",
    //     "90"
    // ],
    "python.linting.mypyEnabled": true,
    "python.linting.mypyPath": "${workspaceFolder}\\.venv\\Scripts\\mypy.exe",
    // "python.linting.pylintArgs": [
    //     "--generate-members"
    // ],
    // "python.linting.pylintEnabled": true,
    "python.pythonPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
    "python.terminal.activateEnvironment": true,
    "python.testing.pytestArgs": [
        "${workspaceFolder}\\tests"
    ],
    "python.testing.pytestEnabled": true,
    "python.testing.unittestEnabled": true,
    "python.venvPath": ".venv",
    "restructuredtext.builtDocumentationPath": "${workspaceFolder}\\docs\\build\\html",
    "restructuredtext.confPath": "{workspaceFolder}\\docs\\source",
    "restructuredtext.languageserver.disabled": true,
    "restructuredtext.sphinxBuildPath": "${workspaceFolder}\\.venv\\Scripts\\sphinx-build.exe",
    "screencastMode.keyboardOverlayTimeout": 1500,
    "screencastMode.mouseIndicatorSize": 20,
    "screencastMode.onlyKeyboardShortcuts": true,
    "screencastMode.verticalOffset": 0,
    "security.workspace.trust.untrustedFiles": "open",
    "shellcheck.customargs": [
        "-x"
    ],
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "terminal.integrated.fontFamily": "CaskaydiaCove Nerd Font Mono",
    "terminal.integrated.tabs.enabled": true,
    "trailing-spaces.syntaxIgnore": [
        "markdown"
    ],
    "update.enableWindowsBackgroundUpdates": false,
    "vsicons.dontShowNewVersionMessage": true,
    "workbench.colorTheme": "Predawn",
    "workbench.editor.enablePreview": true,
    "workbench.editorAssociations": {
        "*.dcm": "default",
        "*.ipynb": "jupyter-notebook",
        "*.tiff": "tiff.preview",
        "git-rebase-todo": "default"
    },
    "workbench.iconTheme": "material-icon-theme",
    "workbench.settings.editor": "json",
    "workbench.settings.openDefaultSettings": true,
    "workbench.settings.useSplitJSON": true,
    "workbench.startupEditor": "newUntitledFile"
}

为什么会发生这种情况,我该如何修复我的 Intellisense?

更新:

删除"editor.suggestSelection": "first" 有所帮助,但我仍然收到错误:

【问题讨论】:

    标签: visual-studio-code intellisense


    【解决方案1】:

    将以下内容添加到我的 settings.json 可以使 Intellisense 按预期工作:

    "editor.acceptSuggestionOnEnter": "off",
    "editor.tabCompletion": "on"
    

    为什么默认值分别是"on" 和"off",我永远不会知道。如果您想使用该建议,每个人都希望按tab(例如在bash terminal 中),并且没有人希望在按回车时盲目地完成自动完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 2016-08-10
      • 1970-01-01
      • 2017-10-15
      • 1970-01-01
      相关资源
      最近更新 更多