question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect syntax colouring in `for` loops

See original GitHub issue

Environment data

VSCode - Version: 1.46.0-insider MS Python Extension - v2020.5.78807 macOS 10.14.6 Mojave Python 3.9.0 Virtual Environment - N/A It first showed up in github.com/craffel/pretty-midi python.jediEnabled: false python.languageServer - not set - defaults to 'Microsoft" python.languageServer setting: not set

Have not been able to explicitly set the Python Language Server - is this the problem?

Expected behaviour

Note the syntax colouring of for imstrument in.

Screenshot 2020-05-15 at 14 21 18

Actual behaviour

Note the syntax colouring of for instrument in.

Screenshot 2020-05-14 at 22 24 20

Note, that I changed the theme between the two images; I was trying to determine if the problem was todo with the theme itself - apparently not!

Steps to reproduce:

Construct a for loop where the for variable contains the letters `in within the name.

[EDIT] Construct a for` loop where the variable contains any reserved word within the name…

[EDIT] Not all reserved words cause this problem.

Screenshot 2020-05-15 at 16 09 10

Logs

> /usr/local/bin/python3.9 ~/.vscode-insiders/extensions/ms-python.python-2020.5.78807/pythonFiles/pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/code/python/midi/test_pretty_midi.py
cwd: ~/code/python/midi
> /usr/local/bin/python3.9 ~/.vscode-insiders/extensions/ms-python.python-2020.5.78807/pythonFiles/pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/code/python/midi/test_pretty_midi.py
cwd: ~/code/python/midi
##########Linting Output - pylint##########

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
nulliecommented, May 19, 2020
0reactions
ericsnowcurrentlycommented, May 19, 2020

@carlca, syntax highlighting for Python is actually configured in VS Code rather than the Python extension (also true for many other languages). So this will need to be handled upstream.

@nullie, yes, please open a new issue in VS Code. Feel free to link to this issue there (or to that issue here).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax highlighting not working for Python in VS Code with ...
I'm trying to get Visual Studio Code to format (the colours not the layout) Python code with type annotations (hinting).
Read more >
Visual studio showing wrong syntax highlighting color when ...
see strange highlights/color, in the IDE, on the code I wrote on each project/solution. It's as if the IDE is displaying colors of...
Read more >
Incorrect syntax highlighting? "Variables made special by use ...
How do I get the i of Do2 to be under "Variables made special by use in arguments"? It seems like it should...
Read more >
syntax highlight steps within macros and %do loops
It's frustrating when you write a %macro function and/or a %do loop, and the DATA and PROC steps inside are not colored according...
Read more >
Forval loop invalid syntax - Statalist
Hello, I am using forval code as below and then it says it is 'invalid syntax'. ... that color changed to the black...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found