Fending off Pylance errors when using Jupyter magic commands in VSCode
Magic commands are flagged as errors in VSCode by Pylance
as they are not Python.
Setting "jupyter.interactiveWindow.textEditor.magicCommandsAsComments": true
and prefacing commands with # !
means these commands can still be run but disables these errors. (Ref.. NB: Adding a space between #
and !
fends off a separate flake8
error.)
E.g.:
1
# !%timeit run_sql_query(script, connection)
This post is licensed under CC BY 4.0 by the author.