如何修复 pylance 语法高亮显示错误颜色的自我和 cls python class 参数在 VSCode 启用默认主题

How to fix pylance syntax highlighting showing wrong color for self and cls python class parameters in VSCode with enabled default theme

我在使用 Pylance 时遇到了这个问题,并且在默认情况下 VSCode 或 visual studio 2019 主题中为 python 启用了语法突出显示。

self 和 cls 参数与其他参数一样是 LightSkyBlue 颜色

应该是这样的:

我设法找到了一种解决方案,可以覆盖 vscode settings.json 中的颜色代码。这是正确的解决方案吗?

// correct color self and cls python files
"editor.semanticTokenColorCustomizations": {

    "[Visual Studio 2019 Dark]": {
        "rules": {
            "selfParameter": "#569CD6",
            "clsParameter": "#569CD6"
        }
    },
    "[Default Dark+]": {
        "rules": {
            "selfParameter": "#569CD6",
            "clsParameter": "#569CD6"
        }
    }

},

此设置后:


我使用这些页面来获取此设置代码:

https://github.com/microsoft/pylance-release/issues/323

https://github.com/microsoft/vscode/issues/118946