biopython / biopython

Official git repository for Biopython (originally converted from CVS)
http://biopython.org/
Other
4.37k stars 1.75k forks source link

Apply black to Tests/ #2552

Closed peterjc closed 4 years ago

peterjc commented 4 years ago

This is a spin out from #2008, where we have agreed to adopt the black code formatting tool for Biopython:

https://github.com/psf/black

That issue focused on applying black to the main code base (Bio/, BioSQL/, and also Scripts/ and Doc/examples/).

This issue is for applying black to the Biopython test suite.

In principle this is a good issue for new contributors. However, many of the tests include expected data values, so compared to the Biopython main code there are more likely to be cases where black does a bad job - which will need some discussion (e.g. can it be improved with extra brackets, or do we turn off black for a portion of a test file?).

You will need to install black, flake8, and associated plugins as described in https://github.com/biopython/biopython/blob/master/CONTRIBUTING.rst - and we recommend turning on the git pre-commit hook).

Example workflow:

git checkout master # and make sure it is up to date
git checkout -b black_test_XXX # start a new branch
black Tests/test_XXX.py  # do the conversion
flake8 Tests/test_XXX.py # check for string concatenation etc
emacs Tests/test_XXX.py  # review and make any fixes
git commit Tests/test_XXX.py -m "Apply black to Tests/test_XXX.py"
git push my_fork black_text_XXX  # push the branch to your personal GitHub

To avoid duplication of effort, please comment here if you are going to work on a particular file, or group of files.

peterjc commented 4 years ago

If you want to do a few related files together on a single pull request, that's fine too. e.g. Tests/test_SeqIO_*.py

mariecrane commented 4 years ago

I'll work on Tests/test_Uniprot.py

jvfe commented 4 years ago

I'll work on test_Emboss.py and test_Clustalw_tool.py, fixing what was mentioned in #2835 as well.

mariecrane commented 4 years ago

I can work on Tests/test_KEGG.py

jvfe commented 4 years ago

I'll work on test_HMM*

jvfe commented 4 years ago

I'll work with the remaining test_*_tool.py

jvfe commented 4 years ago

I'll work on the remaining test_C*.py

jvfe commented 4 years ago

I'll work on test_pairwise*.py and test_AlignI*.py

jvfe commented 4 years ago

I'll work on test_P*.py

jvfe commented 4 years ago

I'll work on test_align*.py

jvfe commented 4 years ago

I'll work on test_Seq*.py and test_N*.py

jvfe commented 4 years ago

I'll work on the remaining tests, some also require changing assert statements, as specified in #2835, most should be minor changes and easy to merge.

peterjc commented 4 years ago

@jvfe the final pull request to close this will be to update the flake8 configuration to stop ignoring black: https://github.com/biopython/biopython/blob/master/.flake8 setting per-file-ignores =

And make a slight edit to https://github.com/biopython/biopython/blob/master/CONTRIBUTING.rst

And it would deserve mention in https://github.com/biopython/biopython/blob/master/NEWS.rst

peterjc commented 4 years ago

Almost there...

$ cd Tests/
$ black --check .
would reformat /Users/xxx/repositories/biopython/Tests/requires_wise.py
would reformat /Users/xxx/repositories/biopython/Tests/requires_internet.py
would reformat /Users/xxx/repositories/biopython/Tests/search_tests_common.py
would reformat /Users/xxx/repositories/biopython/Tests/PAML/gen_results.py
would reformat /Users/xxx/repositories/biopython/Tests/seq_tests_common.py
would reformat /Users/xxx/repositories/biopython/Tests/pairwise2_testCases.py
would reformat /Users/xxx/repositories/biopython/Tests/test_Seq_objs.py
jvfe commented 4 years ago

Almost there...

$ cd Tests/
$ black --check .
would reformat /Users/xxx/repositories/biopython/Tests/requires_wise.py
would reformat /Users/xxx/repositories/biopython/Tests/requires_internet.py
would reformat /Users/xxx/repositories/biopython/Tests/search_tests_common.py
would reformat /Users/xxx/repositories/biopython/Tests/PAML/gen_results.py
would reformat /Users/xxx/repositories/biopython/Tests/seq_tests_common.py
would reformat /Users/xxx/repositories/biopython/Tests/pairwise2_testCases.py
would reformat /Users/xxx/repositories/biopython/Tests/test_Seq_objs.py

Oh, must've missed those cause I checked test_*. I'll do another PR for them.

peterjc commented 4 years ago

And we're done - a real team effort, thank you to everyone including all the BCC2020 CoFest participants who helped with the final push.