Skip to content

Instantly share code, notes, and snippets.

@tecandrew
Last active November 9, 2022 18:07
Show Gist options
  • Save tecandrew/c1d7e219086946c6f02bce3b9aadb2fe to your computer and use it in GitHub Desktop.
Save tecandrew/c1d7e219086946c6f02bce3b9aadb2fe to your computer and use it in GitHub Desktop.
Python Problem Matcher for VS Code

VS Code

There is no native Python "problemMatcher" for vscode tasks. Use the regexp pattern to make it work for basic tasks.

"problemMatcher":
    {
        "fileLocation": "absolute",
        "pattern": [
            {
                "regexp": "^\\s+File \"(.*)\", line (\\d+), in (.*)$",
                "file": 1,
                "line": 2
            },
            {
                "regexp": "^\\s+(.*)$",
                "message": 1
            }
        ]
    }
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Python: Run Script",
"type": "shell",
"command": "python3",
"args": [
"${workspaceFolder}/myscript.py",
],
"group": "test",
"problemMatcher":
{
"fileLocation": "absolute",
"pattern": [
{
"regexp": "^\\s+File \"(.*)\", line (\\d+), in (.*)$",
"file": 1,
"line": 2
},
{
"regexp": "^\\s+(.*)$",
"message": 1
}
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment