microsoft / microsoft/monaco-editor
[Bug] Python syntax highlighting does not support underscores in numeric literals
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `# '100_000' should be formatted as a single value per https://peps.python.org/pep-0515/
numeric_literal_example = 100_000`;
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "python",
automaticLayout: true,
});
Reproduction Steps
Open the playground link. Verify that 100_000 is formatted inconsistently.
Actual (Problematic) Behavior
Numeric literals with underscores are not highlighted as a single value by the syntax highlighter.
Expected Behavior
Numeric literals with underscores should be highlighted as a single value, as is done in VS Code.
Additional Context
Numeric literals with underscores were proposed in https://peps.python.org/pep-0515/ and have been supported since Python 3.6.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Monaco Editor Playground and reproduce the Python example containing 100_000. Locate the Python syntax-highlighting definition used by Monaco and compare its behavior with the expected VS Code highlighting. Done means the numeric literal is highlighted as one value while existing Python highlighting remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100