Tamas
Tamas

Reputation: 53

VS Code Python debugging justMyCode=False does not allow to step into external code

By debugging a Python code in VS Code I want to step into routines of matplotlib package. By right mouse click I can open the code definition in the package source code, but I cannot step into it during debugging.

I use the newest VS Code with Pylance and Python extensions from Microsoft:

Version: 1.74.2 (system setup) Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161 Date: 2022-12-20T10:29:14.590Z Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.18363 Sandboxed: No

Python 3.10.5 64-bit

Following several hints on Stack overflow I created a launch.json file in the workspace.vscode program directory and added a new configuration:

        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "test",
            "justMyCode": false
        }

I expected that upon debugging using the new configuration "Debug Unit Test" I can then step into external code, but it was not the case. Actually, the "test" value in "request" tag is marked as not accepted. I also tried "launch" there, but it also did not help.

Following another hint I also tried

        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "launch",
            "debugOptions": ["DebugStdLib"],
            "justMyCode": false
        }

The "debugOptions" property is however, not allowed.

I also searched for justMyCode parameter in VS Code settings and found only for Jupyter extension, not for Python.

Is it possible that VS Code discontinued this option for Python debugging??

Upvotes: 2

Views: 2247

Answers (1)

trouble_shooter
trouble_shooter

Reputation: 46

Looking at the documentation it appears you need to add the following configuration:

{ 
  "name": "Python: Debug Tests",
  "type": "python",
  "request": "launch",
  "program": "${file}",
  "purpose": ["debug-test"],
  "console": "integratedTerminal",
  "justMyCode": false
}

I had the same issue but after adding the above to my launch.json I could step into code other than my own.

https://code.visualstudio.com/docs/python/testing#_debug-tests

Upvotes: 3

Related Questions