1) Add black and isort to dev requirements and upgrade any locked requirements
NOTE black will only work on Python 3.6 up! So you may need to do something clever to install it on those ones only, or you may need to just not add it at this stage.
For example, here's how to do it in setup.py:
extras_require_test = ["pytest", "flake8", "isort"]
if sys.version_info[0] >= 3 and sys.version_info[1] >= 6:
extras_require_test.append("black==19.10b0")
Lock black to version 19.10b0 (latest version at time of writing). If there is now a later version, it's ok to lock to that.
This is so that new major versions with breaking backwards changes don't unexpectedly cause issues in pull requests. We lock to an exact version rather than 19.* to avoid a Travis bug we saw.
So far i have the below:
1) Add black and isort to dev requirements and upgrade any locked requirements
NOTE black will only work on Python 3.6 up! So you may need to do something clever to install it on those ones only, or you may need to just not add it at this stage.
For example, here's how to do it in setup.py:
Lock black to version 19.10b0 (latest version at time of writing). If there is now a later version, it's ok to lock to that.
This is so that new major versions with breaking backwards changes don't unexpectedly cause issues in pull requests. We lock to an exact version rather than 19.* to avoid a Travis bug we saw.
2) Add .isort.cfg
Contents are: https://raw.githubusercontent.com/OpenDataServices/lib-cove/master/.isort.cfg
Add to Git
3) Add/Update setup.cfg
Contents are: https://raw.githubusercontent.com/OpenDataServices/lib-cove/master/setup.cfg
Add to Git
3) Run locally
4) Add to Travis install section
If you didn't find a way to install Black above, you need to add something like:
5) Add to Travis test section
6) Git commit into one large commit
7) Amend Author
8) push - Travis should pass!
9) Test by making a new branch, and editing a formatting thing - black should fail!
10) Test by making a new branch, and reordering some imports - isort should fail!