`black` python formatter can't be installed any longer for the version specified in our formatting script
Hey y'all
I ran the python formatting script in a fresh copy of the repository, and the setup of the venv for the black formatter is failing:
$ ./format_python.sh
Formatting environment not found, installing it...
Collecting black==19.3b0
Using cached black-19.3b0-py36-none-any.whl (89 kB)
Collecting attrs>=18.1.0
Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting appdirs
Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting click>=6.5
Using cached click-8.1.2-py3-none-any.whl (96 kB)
Collecting toml>=0.9.4
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Installing collected packages: attrs, appdirs, click, toml, black
Successfully installed appdirs-1.4.4 attrs-21.4.0 black-19.3b0 click-8.1.2 toml-0.10.2
Formatting SWIFT Python scripts
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/mivkov/EPFL/rt/swiftsim-rt-tools/black_formatting_env/lib/python3.8/site-packages/black.py", line 3758, in <module>
patched_main()
File "/home/mivkov/EPFL/rt/swiftsim-rt-tools/black_formatting_env/lib/python3.8/site-packages/black.py", line 3753, in patched_main
patch_click()
File "/home/mivkov/EPFL/rt/swiftsim-rt-tools/black_formatting_env/lib/python3.8/site-packages/black.py", line 3742, in patch_click
from click import _unicodefun # type: ignore
ImportError: cannot import name '_unicodefun' from 'click' (/home/mivkov/EPFL/rt/swiftsim-rt-tools/black_formatting_env/lib/python3.8/site-packages/click/__init__.py)
apparently the upstream package 'click' made some changes, which the older black
versions can't handle any longer.
Newer versions, e.g. 22.3.0, are installing fine.
But trying it out re-formats a lot of our current scripts (163 files reformatted, 112 files left unchanged.)
From what I see, most of the changes are removing the whitespace (black itself introduced) when using the power operation:
# 32^3 particles.
-n_p = 32 ** 3
+n_p = 32**3
So what do we do? Update the version and reformat everything again?