This page was generated from tests/data/notebooks/notebook_with_flake8_tags.ipynb. Interactive online version: Binder badge # noqa: E501

This notebook demonstrates flake8_nb reporting with flake8-tags

Testing Celltags

The next cell should not report F401 'not_a_package' imported but unused, due to the cell tag flake8-noqa-cell-F401.

But it will report E231 missing whitespace after ':', for line 2.

[1]:
import not_a_package
{"1":1}
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-e5f2776a04db> in <module>
----> 1 import not_a_package
      2 {"1":1}

ModuleNotFoundError: No module named 'not_a_package'

The next cell should not report E231 missing whitespace after ':' for line 1, due to the line tag flake8-noqa-line-1-E231.

But it will report E231 missing whitespace after ':', for line 2.

[2]:
{"2":1}
{"2":2}
[2]:
{'2': 2}

The next cell should not report E231 missing whitespace after ':', due to the line tag flake8-noqa-cell-E231.

[3]:
{"3":1}
{"3":2}
[3]:
{'3': 2}

Testing inline Celltags

The next cell should not report F401 'not_a_package' imported but unused, F811 redefinition of unused 'not_a_package' and E402 module level import not at top of file, due to the inline cell tag flake8-noqa-cell-E402-F401-F811.

But it will report E231 missing whitespace after ':', for line 3.

[4]:
# flake8-noqa-cell-E402-F401-F811
import not_a_package
{"4":1}
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-4da0e31bdfa0> in <module>
      1 # flake8-noqa-cell-E402-F401-F811
----> 2 import not_a_package
      3 {"4":1}

ModuleNotFoundError: No module named 'not_a_package'

The next cell should not report E231 missing whitespace after ':' for line 2, due to the inline line tag flake8-noqa-line-2-E231.

But it will report E231 missing whitespace after ':', for line 3.

[5]:
# flake8-noqa-line-2-E231
{"5":1}
{"5":2}
[5]:
{'5': 2}

The next cell should not report E231 missing whitespace after ':', due to the inline cell tag flake8-noqa-cell-E231.

[6]:
# flake8-noqa-cell-E231
{"6":1}
{"6":2}
[6]:
{'6': 2}

Testing normal flake8 noqa comments

The next cell should not report E231 missing whitespace after ':' for line 1, due to the flake8 noqa comment #noqa: E231.

But it will report E231 missing whitespace after ':', for line 2.

[7]:
{"5":1}  # noqa: E231
{"5":2}
[7]:
{'5': 2}

Report using execution count

[8]:
!flake8_nb notebook_with_flake8_tags.ipynb
notebook_with_flake8_tags.ipynb#In[1]:2:5: E231 missing whitespace after ':'
notebook_with_flake8_tags.ipynb#In[2]:2:5: E231 missing whitespace after ':'
notebook_with_flake8_tags.ipynb#In[4]:3:5: E231 missing whitespace after ':'
notebook_with_flake8_tags.ipynb#In[5]:3:5: E231 missing whitespace after ':'
notebook_with_flake8_tags.ipynb#In[7]:2:5: E231 missing whitespace after ':'

Report using code cell count

[9]:
!flake8_nb --notebook-cell-format '{nb_path}:code_cell#{code_cell_count}' notebook_with_flake8_tags.ipynb
'notebook_with_flake8_tags.ipynb:code_cell#1':2:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:code_cell#2':2:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:code_cell#4':3:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:code_cell#5':3:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:code_cell#7':2:5: E231 missing whitespace after ':'

Report using total cell count

[10]:
!flake8_nb --notebook-cell-format '{nb_path}:cell#{total_cell_count}' notebook_with_flake8_tags.ipynb
'notebook_with_flake8_tags.ipynb:cell#4':2:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:cell#6':2:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:cell#11':3:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:cell#13':3:5: E231 missing whitespace after ':'
'notebook_with_flake8_tags.ipynb:cell#18':2:5: E231 missing whitespace after ':'