pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Ignoring *.ipynb files does not work

Open taldcroft opened this issue 4 years ago • 3 comments

Describe the bug Here is my pyrightconfig.json file:

{
  "ignore": [
    "**/commands_archive.py",
    "**/*.ipynb"
  ]
}

I confirmed that the commands_archive.py is ignored (as expected) by introducing an error in that file and noting that the error is not reported. However, the Jupyter notebooks in my project are not ignored and generate a large number of errors:

To Reproduce Using VS code, create a Jupyter notebook and include that pyrightconfig.json in the project.

Expected behavior No Pylance / pyright errors should be reported for any file named *.ipynb.

VS Code extension or command-line Running as a VS Code extension Pyright version v1.1.192.

taldcroft avatar Dec 03 '21 11:12 taldcroft

This happens because pyright doesn't see the file as a "*.ipynb". The file is being preprocessed (to combine all of the cells) in the notebook by the VS Code Python extension, and the resulting combined file is then passed to pyright for analysis.

The pylance team is actively working on changing the way this works. I'm going to transfer this bug to the pylance-release repo so it gets the attention it deserves.

erictraut avatar Dec 03 '21 18:12 erictraut

@erictraut - ah ok, that makes sense. Thanks for clarifying this and I'll be hoping for a fix in pylance.

taldcroft avatar Dec 03 '21 19:12 taldcroft

@judej we should discuss whether we should consider ipynb (opened in vscode) as something affected by pyrightconfig or mspythonconfig.json

heejaechang avatar Jan 03 '22 21:01 heejaechang

Still doesn't work with LSP notebooks because each cell is treated as its own file and those "fake" cell paths have additional data after the .ipynb extension.

While waiting for a fix you could work around this issue by ignoring "**/*.ipynb*" instead.

debonte avatar Aug 23 '22 22:08 debonte

This issue has been fixed in version 2022.8.51, which we've just released. You can find the changelog here: CHANGELOG.md

bschnurr avatar Sep 01 '22 21:09 bschnurr