Repository navigation
Description
I'm logging this as a good first issue ideal for a new contributor (but if you are the maintainer of any of the files listed here, feel free to fix them yourself). If you want to work on this, I suggest commenting first saying something like "I'll work on Bio/SwissProt to start with" in order to avoid duplicated effort.
If you use the code checking tool flake8 with the bugbear plugin, it finds a number of issues with our code - specifically we have a modest number of assert statements which should ideally be replaced.
You can install the tools as follows:
$ pip install --upgrade flake8 flake8-bugbear
Run flake8 to look for this problem specifically:
$ flake8 --isolated --select B011 Bio/ Tests/
Bio/SwissProt/__init__.py:354:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Bio/SwissProt/__init__.py:396:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Bio/SeqIO/PirIO.py:185:5: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Bio/SeqIO/QualityIO.py:1372:5: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Bio/AlignIO/EmbossIO.py:61:9: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Bio/AlignIO/EmbossIO.py:207:17: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_Nexus.py:687:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_SffIO.py:564:9: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/seq_tests_common.py:142:17: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/common_BioSQL.py:328:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/common_BioSQL.py:356:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/common_BioSQL.py:367:17: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/common_BioSQL.py:406:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/common_BioSQL.py:428:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/common_BioSQL.py:701:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_GenomeDiagram.py:695:17: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_GenomeDiagram.py:702:17: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_Fasttree_tool.py:82:5: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_Fasttree_tool.py:102:9: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_Fasttree_tool.py:114:5: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_SeqIO.py:636:17: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_SeqIO.py:690:17: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_SeqIO_convert.py:66:9: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_SeqIO_convert.py:76:9: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_AlignIO.py:227:9: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_AlignIO.py:254:9: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
Tests/test_AlignIO.py:332:13: B011 Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().
In the Tests/ cases, within a unittest based class they should probably use self.assertTrue(...) instead.
Otherwise, and in the Bio/ cases, they should probably be reworked to an if-statement raising a ValueError or similar.
See also #1515 which looked at multi-line assert statements which failed other flake8 style rules, and has some relevant discussion and examples.
Activity
peterjc commentedon Apr 18, 2019
See also 4cf0c19 which added B011 and a few other issues flagged by
flake8-bugbearto our default ignore lists.Once all the B011 cases are fixed, we can remove these from the ignore list - and perhaps start using
flake8-bugbearas part of the automated testing too.benjaminr commentedon Apr 21, 2019
Happy to look at resolving all of these.
Stop ignoring flake8-bugbear B011
Bugfix/fix use of assert - issue #2015 (#2023)
peterjc commentedon Apr 22, 2019
Turned out there was a configuration error meaning TravisCI was not testing with
flake8-bugbear, fix in hand #2025Stop ignoring flake8-bugbear B011
peterjc commentedon Apr 22, 2019
All done, thank you!
benjaminr commentedon Apr 22, 2019
No problem!
Bugfix/fix use of assert - issue biopython#2015 (biopython#2023)
Stop ignoring flake8-bugbear B011