4

I have encountered this issue when I use Pylance and syntax highlighting is enabled for python in the VSCode with default or the visual studio theme.

self and cls parameter are LightSkyBlue color like other parameters before

It should be like this:

should be this

Pedram Elmi
  • 151
  • 8

1 Answers1

6

Added the color code inside the settings.json file for the dark themes I use.

// correct color self and cls python
"editor.semanticTokenColorCustomizations": {
    "[Default Dark+]": {
        "rules": {
            "selfParameter": "#569CD6",
            "clsParameter": "#569CD6"
        },
    },
    "[Visual Studio Dark]": {
        "rules": {
            "selfParameter": "#569CD6",
            "clsParameter": "#569CD6"
        },
    },
    "[Default Dark Modern]": {
        "rules": {
            "selfParameter": "#569CD6",
            "clsParameter": "#569CD6"
        },
    }
},

Add theme settings based on what theme you are using. for example, I just changed my theme to [Default Dark Modern] and then added the color settings.

These two issues on pylance and vscode github repository helped:

Pedram Elmi
  • 151
  • 8
  • This doesnt seem to work on latest visual studio and pylance, with the error: `Property rules is not allowed.` – Nanyo Mar 10 '22 at 20:58
  • @Nanyo thank you for the comment. I checked it on my VSCode. The setting config still works for me and if I remove it, it will make `self` and `cls` LightSkyBlue color again. VSCODE Version = February 2022 (version 1.65) Pylance Version = v2022.3.2 – Pedram Elmi Mar 22 '22 at 21:59
  • @Nanyo did you hit the same issue I did, putting this in "workbench.colorCustomizations" and not "editor.semanticTokenColorCustomizations" as is in this answer? – seaders Sep 18 '22 at 21:12
  • 1
    @seaders Yes, that was exactly what I did. A bit silly but still new to all this :) – Nanyo Nov 18 '22 at 00:18
  • I am using VSCode 1.80 (June 2023), and I am facing the issue that if I have my Python extension enabled, it immediately overwrites the coloring to the default one. Have you faced that? – SBF Jul 13 '23 at 15:27
  • @SBF No. Did you add the settings for your active theme? I just edited the answer. – Pedram Elmi Jul 24 '23 at 13:47
  • @PedramElmi you mean, did I specify that this to be applied to a specific theme in the settings.json? – SBF Jul 24 '23 at 13:53