-
Notifications
You must be signed in to change notification settings - Fork 45
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
Going black (i.e. adopting an _opinionated_ python code formatter) #324
Comments
(Personally, I don't love black because I prefer using |
I had similar reservations about I'd also recommend using |
I'm happy with |
I feel the same! (both about |
I thought the
I vote 1 About |
It's easy enough to just incorporate
I think that fits with what you're saying. |
I'm happy with @tsalo 's suggestion. |
@tsalo would you be able to set up the PR? |
Will do! |
Thanks! Once you open it, you can label it internal and assign the PR to me - I'm going to MRev it! |
Sorry for the slow response - this all sounds fine to me as long as there is some guidance/documentation on how to incorporate black locally if that's what we go for. 😅 Not that I am doing that much Python coding but one day ... |
I was already thinking about proposing it, but then @tsalo applied it on his #219 so it's a good moment to propose it.
In the line of automating all that is automatable, there is one more thing we should adopt, a code formatter.
Code formatters are scripts that chew our code and our PRs and spit out a standardised formatted version of the code, as long as the code doesn't contain big mistakes. They shouldn't change radically the code, rather adjust it with simple rules like "always use
'
instead of"
for strings" or "always adopt a certain indentation rule in your scripts". "Chill" code formatters just check that a coding style is respected (e.g.autopep8
checks thatpep8
is respected), while there are "opinionated" code formatters that format the code even if it respect a standard (in our case,pep8
).One (apparently) popular opinionated python code formatter is black. It's very strict and either we agree with its rules or we don't.
Another opinionated code formatter is YAPF. It's less strict, in the sense that it allows for some customisations, but it does a similar job.
There are pros and cons in adapting a code formatter.
The biggest pro: our code will always be formatted in the same way, independently from its author, so we can forget comments like "please reformat following our style" in reviews and other minutiae.
Cons: If we ask the commits to be already formatted, contributors needs to run black locally before a PR. Alternatively, if we run it during a PR merge (we need to understand how to do it smartly), the code that we will see in the repo might not be exactly the same that we wrote - although it will be very similar.
@physiopy/all, what do you think about adopting an opinionated code formatter? And what do you think about adopting black?
Outstanding questions
PS: Labelling this urgent because we might need to wait for this before merging #219 - and we need to do that in the upcoming month. Deadline is next dev call (remember that next month it will be during the first week).
The text was updated successfully, but these errors were encountered: