s-weigand / flake8-nb

Flake8 checking for jupyter notebooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

--exclude flag

peisenha opened this issue · comments

  • flake8-nb version: 0.1.4 (mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.7.3 on Linux

  • Python version: 3.7.6

  • Operating System: Ubuntu

Description

We are trying to exclude subdirectories from the checks.

What I Did

First of all, thank you very much for providing such a useful tool! We are trying to integrate it into our groups's research workflow and are struggling to exclude subdirectories from the checks. See below.

(base) peisenha@heracles:~/Desktop/test$ flake8-nb --exclude=subdir
main.ipynb#In[1]:1:1: F401 'numpy as np' imported but unused
subdir/subdir.ipynb#In[ ]:1:1: F401 'numpy as np' imported but unused

Any guidance is highly appreciated. Thanks, @peisenha @rafaelsuchy

As in flake8, exclude uses a glob pattern for files, so this should do the trick:

$ flake8-nb --exclude=subdir/*

If you are working collaboratively, I would recommend using a project wide configuration.
You should also keep in mind that changing exclude (in the config or as CLI option), will overwrite the default value *.tox/*,*.ipynb_checkpoints*.

I hope this helps.

That is kind of the issue, that the usual behavior does not appear to apply.
Screenshot from 2020-05-19 12-18-30

Let me know if I am missing sth. obvious here ...

I could reproduce the same behaviour, from your example.Strangely, when testing it in my project directory with the test files it was working as expected.
Keep tight I will investigate and fix it.

Great, thanks a lot for your swift response!

I think I got the bug.
I wasn't passing the exclude option to the notebook collector.
When testing locally I only exclueded the tests/data/intermediate_py_files path, but those files were collected by the real flake8, which lead me to believe that it works 😅 .
Could just test if the current master works?

pip install git+git://github.com/s-weigand/flake8-nb

If it does, I will do some more chores and publish a new version

@s-weigand , works as expected now. Thanks a lot!

Ok so just some chores and there will be a new version on PyPi.