-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use black for zopefoundation repositories? #6
Comments
What problem are we trying to solve with yet more bureaucracy? I'm horrified by some of the defaults, and if you don't use defaults you have to suddenly go through and create configurations on all repositories? A strong |
Minimizing bikeshedding by enforcing styles mechanically in a way that's objectively popular (even if horrifyingly objectionable). It takes the subjectivity out of these inherently subjective concerns. |
I disagree. The subjectivity is just being moved from the project's own flake8 rule decisions to an outside entity. It feels like it's just easier to tell people who don't like the rules "hey, don't complain to us, we didn't make these rules, bitch at the black project". Secondly, I don't know how it is on the Plone side, but here we do not have an issue with any noticeable disagreement to the current setup. This isn't a problem here so it doesn't need solving. |
P.S.: Just to clarify, I am speaking only for the zopefoundation repository side. If the Plone repository maintainers think this is a good idea for them, more power to them. |
From my perspective, it's best for a project to choose one of two philosophies: either allow all contributors to contribute in their preferred style or have a system that mechanically applies the style. Every compromise in between leads to subjective and manually-intensive application of whatever style is desired. Having spent a substantial portion of the past two years being forced by tools like flake8 to "try again", I'm utterly sick of that and am adopting black so I don't have to do that work any more. |
I'm -1e6 on the idea, myself. I've just lived through this for It will pretty much destroy using "git blame" to figure out why a change was made (the extra effort to remember how to get back beyond the "blackening day" commit means one doesn't try). If you do go this route, certainly kill off the ridiculous 88 character line length and the string normalization (which doesn't even match the CLI's own usage!). |
I am sure there are plenty of tools to automatically apply e.g. the current flake8 config. That's not an argument for choosing yet another tool with yet other style rules, some of which are totally different from what we have been using for many many years. Tres also identified the two items that I was horrified about, the line length and the string normalization. |
In the end (also referring to what I am currently enforcing for the whole developer team at my |
As someone who tries to review most PRs submitted to ZF's repos, I'd rather not have to review the huge initial diffs that Black produces. If y'all make the decision to use Black, can we agree to commit these directly to master? In theory it should be safe, yes? ;) (As for my personal opinion, I'm -0.5 on the idea, but I won't stand in the way.) |
I think adopting black (or whatever equivalent tool) has more pros that cons I am just reporting my experience.
I also used to prefer some other tools rather than black see plone/Products.CMFPlone#2754 (comment), but the point is that any energy spent on this topic is energy drained out from something probably more important. |
There's no energy being spent here. What we have does the job well enough and I have not seen any purported discussions about code style that could be squashed by shifting blame to a different tool. |
A couple of annotations:
No, if you configure pre-commit, which "all the cool kids do nowaydays" (I have not tried it yet).
Well, like 99% of the time when I do git blame see something like "This is the real code", "Get the code" or any other 10+ year old commit message, at least at that areas I worked on. Also, at least PyCharm (and maybe other IDEs, too) supports going back more than one commit to view the history of a line.
As PyCharm has some sensible checks, I never used flake8 before. I just installed it and ran it on Products.MailHost, which I plan to update today. And all I got was this: So. Either "flake8" was not run at this project or my flake8 installations (VirtualEnv with py2.7 / py3.6 and via pipx) are all broken. Or flake8 is buggy. So, if we agree upon flake8 is enough, it should be documented at least somewhere. At PyConWeb in Munich this weekend there were a couple of interesting talks, amongst some on black ( https://gist.github.com/zupo/eb6dbfb98bc7548adb8d9208a8e3f57a ) and one on how a guy created a new web framework. The interesting part was that he explained how he tried to encourage contribution and the creation of a community, and one point was to create a good "CONTRIBUTING" document, which we currently lack. The slides: The article: His CONTRIBUTING document: That all said.... I am a lot less emotionally touched by this decision. If we go for it, very fine, if we do not go for it (yet), well, that's ok, too. I think in 5 years nobody will talk about it, as everybody will use it. |
Jürgen you don't install anything to run the flake8 checks. You run the buildout and then |
Thanks! |
So, I created a pull request for Products.MailHost, which failed at first because of flake8 issues, as Products.MailHost enforces single quotes - which e.g. Zope and other projects do not. Something like this would not have happened if we went for black with defaults. The one key difference between flake8 and black is:
|
@jugmac00 the single quotes are enforced for consistency. That whole codebase uses them. black tells you what to do as well, and with even stranger defaults. I don't see the difference. Even if you're rightfully arguing that we have diverging flake8 configurations across zopefoundation repositories, black is not a magic panacea for that, sorry. To avoid Travis CI runs going red you run Again, I believe black is answering a question that has not been asked on our zopefoundation side. |
Black does not tell me what to do, it does it for me. When I run black (or the pre-commit hook does it for me), I do not get an output like But as I said, I do not strongly lean towards one or the other side. I am fine with flake8, too - as long as we try to use it consistently over the zopefoundation repos. |
Most of the actively developed packages have a flake8 linting configuration. They differ in details, as you noticed yourself. You'll probably never have a situation where you reach complete consistency across all repositories, unless someone spends a lot of time setting it up/comparing it for all repositories. IMHO that's a non-goal, anyway. No one should spend time updating dead packages, of which there are a lot. At that point I'd be back at my question: Where is the actual problem we are trying to solve that is not solved by what we have right now? |
We have evaluated black for Shoobx code and I have veto'ed its use. Since it indiscriminately formats everything, a lot of my purposefully grouped formatting would be lost. Also, I do not buy the premise of minimizing merge diffs since it increases vertical space a lot. And I read code much more than merge diffs. On the other hand, given the chatter at the Language Summit a few weeks back, it is pretty much a lost battle at this point. |
As For now I am going to close this issue as there is no consensus about using Maybe we should try it in a small project before thinking about using it on a larger code base. |
The Plone developers are planning to use https://pypi.org/project/black/ for upcoming Plone versions.
I see the following Pros:
and these Cons:
We would have to decide about the few options
black
provides:--skip-string-normalization
to keep the diffs smallerIt would require the following work in each repository:
tox
and in TravisCI in addition to Flake8 to keep the codeblack
.Any opinions for this proposal?
The text was updated successfully, but these errors were encountered: