Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-format python code with 'black' #743

Merged
merged 5 commits into from
Sep 29, 2021
Merged

Auto-format python code with 'black' #743

merged 5 commits into from
Sep 29, 2021

Conversation

michaeljones
Copy link
Collaborator

@michaeljones michaeljones commented Sep 27, 2021

This PR shows what it would look like to format the code base with black. Since using elm-format and prettier I've become a big fan of auto-formatters. Sometimes the result isn't ideal but generally you get use to it and being able to relax and just let it happen is great.

Happy to have thoughts and feedback on this.

A significant downside is that it is likely to create conflicts for any currently open branches/PRs. I would suggest we focus on merging anything that we're keen on and then reset this branch & re-run black afterwards.

Closes #736

For formatting the code.
@jakobandersen
Copy link
Collaborator

I suggest excluding all files in breathe/parser/.
Recently I looked into updating these files using the code generator you once used (generateDS), but against the newest DTDs from Doxygen to get the latest changes. However, there have been manual changes to those files since, approx. 60 commits if I remember correctly. Some changes are basically what would anyway be generated now, but I didn't get around to check them all.
In the future I think we should let that folder have no manual changes but only regenerated files for each Doxygen release.

With black line-length configuration for the project.

Otherwise it uses 88 which is less than our project standard as checked
by flake8.
Excluding the parser files which are auto-generated once upon a time
possibly best left out for the moment.
We'd rather black had control over all formatting issues so we disable
flake8 warnings about formatting.
@michaeljones
Copy link
Collaborator Author

Thanks for the review. I've changed it to leave out the parser folders for the moment.

I can't clearly remember my thinking around the generated files. I believe I once wanted to be free to regenerate them but found enough issues due to either the xml or the generation script that things seemed to need to be fixed in place and that overriding them in say, subclasses, would end up duplicating a lot of the logic. That said, it has been a long time so revisiting it as a concept might be nice.

Via the Makefile as we've done for the other checks.
@michaeljones
Copy link
Collaborator Author

I'm going to merge this on the basis that auto-formatters are increasingly best practice and black seems popular enough.

@michaeljones michaeljones merged commit 8141c36 into master Sep 29, 2021
@michaeljones michaeljones deleted the black branch January 27, 2022 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce formatter for the code base
2 participants