ignore markdown cells in `jupyter nbconvert` with `--to script`

后端 未结 3 1989
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 00:39

Is it possible to have jupyter nbconvert ... --to script ignore markdown cells rather than convert them to comments?

I\'m asking because I want to use

3条回答
  •  抹茶落季
    2021-01-22 01:17

    I'm asking because I want to use flake8 to check the Python code that's generated

    You can do this directly with nbqa :

    $ nbqa flake8 my_notebook.ipynb --extend-ignore=E203,E302,E305,E703
    my_notebook.ipynb:cell_3:1:1: F401 'import pandas as pd' imported but unused
    

    It also works as a pre-commit hook, see https://nbqa.readthedocs.io/en/latest/pre-commit.html

提交回复
热议问题