-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Using an auto-formatting is a great way to avoid stylistic conflicts/flame-wars in a repository. It also makes it easier for new comers, because the format is similar to what they've seen in other projects.
A popular choice is black. It has a bunch of sensible defaults, but can also be configured per project.
If we put a [tool.black] section in pyproject.toml, every call from within the project will follow the defined styles:
https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-format
This way we can set line-length=120 or whichever is preferred.
(Personally I like 88 because I work on a laptop and like to have many columns of code next to each other, but I'm happy with whatever @okhat chooses.)
It's also possible to create a github action that automatically enforces the format:
https://black.readthedocs.io/en/stable/integrations/github_actions.html
That way you avoid code getting comitted, only to later having to be reformatted.