-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Format code using Black? #10996
Comments
Seems fine to me, although I'd like us to merge PRs before doing this (I recently got a number of PRs merge-conflict free, but haven't had time / knowledge to review them). I'd also prefer it if mypy kept its current line length. |
Personally speaking, I'm quite like the black coding style. Also, I agree that we might still keep the line length to 99. |
Several things need to discuss which would bring lots of style change to current codebase:
|
@97littleleaf11 Those style changes would be necessary, since Black doesn't have many configuration options. Since they would change a large fraction of lines, many open PRs would get merge conflicts. I can dedicate some time to reviewing PRs before we implement the switch. It would be good to have a timeline for the switch announced at least a few weeks ahead of time, so that there's time to merge a bunch of open PRs. |
We now have a PR open for applying Black: #12424 (thanks @KotlinIsland!). As you might imagine, I'm also in support of adopting Black if there's consensus among the other maintainers. A useful tool to add would be pre-commit.ci, which provides a GH Action that can run on PRs and automatically format them. This has been very helpful on typeshed and could ease the pain for existing PRs that would otherwise get merge conflicted after we fix Black. |
I think we don't need to be too nervous about existing PRs. Its pretty easy to automatically rebase such PRs with something like:
Not sure if what the github action does is quite as good as this, it could be an option too for existing PRs. |
Thanks @jhance, I think it's important to communicate these steps onto all conflicting PR's, I will add it to the OP in the Black PR. |
@JukkaL The PR is fully formed I think, what steps should we take next? |
Maybe it's worth adding pycln as it was done in python/typeshed#8304? |
@q0w That seems more like a linter, and less like a formatter. I don't want to bloat this change because it's already hard enough. |
I found a really good strategy to rebase conflicting PR branches:
|
There have been suggestions to use Black to format the mypy (and mypyc) codebase for a long time. Maybe it's time to actually do the switch now?
We'd need a volunteer to drive the project. I don't expect it to be a lot of work, but we'd need to at least update contributor documentation and pip dependencies. We'd also need to decide whether we'd fail a PR if it's not correctly formatted.
Next steps:
The text was updated successfully, but these errors were encountered: