Python formatting
During today's telecon, it was (somewhat jokingly) suggested that we should run the Python formatting tool black
on all Python scripts in the repository to guarantee a more consistent Python style. Since that is not very hard, I gave it a try.
Some surprises: some scripts apparently still used Python 2 syntax. So I ran 2to3
on those as well. Even then, there is one problematic script left:
error: cannot format ./examples/SubgridTests/CosmologicalStellarEvolution/plot_box_evolution.py: cannot use --safe with this file; failed to parse source file with Python 3.6's builtin AST. Re-run with --fast or stop using deprecated Python 2 syntax. AST error message: inconsistent use of tabs and spaces in indentation (<unknown>, line 111)
Is this something we want to do? And if so, do we want to include black
formatting in format.sh
?
If we want to proceed, the following issues need to be dealt with:
-
fix examples/SubgridTests/CosmologicalStellarEvolution/plot_box_evolution.py
formatting -
check that old Python 2 scripts were converted correctly and still do what they need to do
Edited by Bert Vandenbroucke