Automated formatting #2161
Replies: 9 comments 4 replies
-
Regarding 2: I would prefer As far as I understand from the |
Beta Was this translation helpful? Give feedback.
-
Just thought I'd leave a pointer to a currently ongoing discussion on the numpy mailing list that somewhat mirrors our thoughts here: |
Beta Was this translation helpful? Give feedback.
-
I would also prefer |
Beta Was this translation helpful? Give feedback.
-
Another tool we could consider is It can already replace flake8 and isort (and others we are not using), and will probably also provide autoformatting at some point. |
Beta Was this translation helpful? Give feedback.
-
I like using black. It's easy to use and probably makes formatting code a lower hurdle for new users. |
Beta Was this translation helpful? Give feedback.
-
@ESMValGroup/esmvaltool-developmentteam There seems to be a fairly strong preference for using |
Beta Was this translation helpful? Give feedback.
-
+1 for |
Beta Was this translation helpful? Give feedback.
-
To revive this discussion: I think it would be helpful to consistently format our code base with a formatter like We could also do it in a step-by-step procedure just like iris did (they basically ignored most rules at the beginning and slowly enforced them in subsequent PRs). This would lead to smaller PRs which can be reviewed very easily. |
Beta Was this translation helpful? Give feedback.
-
@ESMValGroup/esmvaltool-developmentteam We are considering reformatting the Python code in the ESMValTool repository using the modern |
Beta Was this translation helpful? Give feedback.
-
Automated formatting of Python code is currently done using
yapf
. There were a questions aboutyapf
?yapf
toblack
?Regarding 1) The motivation for formatting all code with a single version of yapf is that it will lead to fewer changes in pull requests if you use yapf to format a file where you only changed a single line of code. An alternative would be to use
yapf-diff
, which only formats the lines of code that have changed and thus avoids the large amount of changes. A downside of this is that it may offer a slightly less consistent look of the code.We had some discussion of this topic at the workshop, if you have an opinion, please share it here!
Beta Was this translation helpful? Give feedback.
All reactions