I know some of you are using Visual Studio Code with its excellent Python extension to do your daily work. There is one major issue with its Notebook and Interactive Window interface though: by default, it will silently swallow warnings!
Now, MNE-Python emits important warnings in several places to inform you about potential problems in your data analysis. Missing these warnings can mean that you’ll run into issues that might be difficult to track down later on.
To make VS Code display all warnings when working in the Notebook or Interactive Window, edit your settings.json
and add the following section:
"jupyter.runStartupCommands": [
"import warnings",
"warnings.simplefilter(action='default')"
]
In my case, settings.json
now looks something like this:
{
...
"python.analysis.typeCheckingMode": "basic",
"workbench.colorTheme": "Default Light+",
"jupyter.runStartupCommands": [
"import warnings",
"warnings.simplefilter(action='default')"
]
}
After that, newly started Notebooks and Interactive Windows should display warnings by default. You can verify this by running the following lines in an Interactive Window:
import warnings
warnings.warn('Warning Message')
This should display a warning:
This issue has been marked as a bug on GitHub; please consider giving a “Thumbs up” to the issue, as the VS Code team prioritizes issues based on popular demand, measured in counts.