visual-studio-codejupyter-notebookpylance

Disable Pylance for a specific Jupyter Notebook command


I use Python Interactive / Jupyter Notebook in Visual Studio Code.

I sometimes use the display command, which runs fine in the Notebook that is opened on the side, but Pylance marks it as:

"display" is not defined Pylance(reportUndefinedVariable)

This probably happens because I am in a .py file, which doesn't recognize this command, but when running it in VS Code, it works just fine.

I would like to ignore this warning only, how can I do that?

For example:

x = 42
display(x) # Pylance flags this

Solution

  • The Pylance can not suppress this warning only, it only can suppress one type of warning, such as this:

      "python.analysis.diagnosticSeverityOverrides": {
        "reportUndefinedVariable": "none"
      },