-
Notifications
You must be signed in to change notification settings - Fork 392
Add pre-commit: pretter, black, pyupgrade, and misc #1381
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
Conversation
Draft reason - I'm debugging a test failure. Resolved by not making
|
603a7bc
to
486ea41
Compare
Also, if we merge this, we'll probably cause immense merge conflicts with most other open PRs... |
Could we pull out the manual fixes here into their own PR and just merge those? Hopefully it'll then be easy to re-base this PR and re-run pre-commit with no manual changes when it's convenient? |
I'll do that.
Yeah, I see no easy solution or set of action points to avoid this. I guess the only thing to do is to make a thorough work nudging all open PRs to resolving into merge/close. |
Can we run the pre-commit checks in GH Actions instead of adding yet another CI provider? The more different providers we use the higher the chances that one of them has an outage, makes changes we have to react to, etc. GH Actions seems to be running well and we use it a lot, so if we can get the tools/checks executed there that would be a win if you ask me. On the topic of this PR changing a lot of code which makes it hard to review the changes (triggered by questions like "is this change really a good one?" as well as making life harder for existing PRs: what concrete problem or pain does a tool like pyupgrade address? |
There was a discussion about pyupgrade on jupyterhub/jupyterhub#3583 (that PR was split into two and merged). I think the big advantage of pyupgade, and autoformatters such as Black or Prettier, is it helps standardise our code which has developed over several years by several different people. If you're new to the code base the different coding styles can be very noticeable and confusing, e.g. you're not sure if the different conventions have a functional effect or not. It also improves general readibility. It's definitely not perfect, but after a lot of prevaricating I now tend to agree with the developers of autoformatters that everyone has there own preference, so in the absence of a strong reason it's better to just go with the defaults. You've indirectly brought up a good point about how we make these sort of wide-ranging changes though, and is perhaps something we should think about in future. It fits in with the discussion about how we make impactful changes such as switching to JupyterLab, except this is developer focussed instead of user focussed. |
@betatim regarding pre-commit.ci, I wrote a comment about it in jupyterhub/team-compass#379 (comment) opened to discuss usage of pre-commit.ci.
Should I perhaps open an issue dedicated to try highlight what it does and with my suggestion to start using it across our repos? I can champion this one because I'm at the stage where I'd like to see it adopted more widely after having seen it piloted successfully without any issues in jupyter/docker-stacks and jupyterhub/jupyterhub now. UPDATE: I opened jupyterhub/team-compass#453 |
How's this for a roll-out plan for the main autoformatting change:
|
486ea41
to
02bebb3
Compare
Thanks @consideRatio for opening up this one - I think that these kinds of mega-PRs are quite tricky because it's so hard to review anything. I've found that the following is a useful order of operations:
If there are other changes that need to be made, I think it's best that we do those separately from the "mega commits" so that it's easier to review. As for implementing this in the |
a15a315
to
cafcd18
Compare
Thanks for input @choldgraf! I've updated this PR with instructions on how to continue based on your suggested approach. |
It's been nearly 5 months since this PR was opened. It will cause disruption to open PRs, but most of those are over a year old. Since there's never going to be a perfect time I think we should update this PR and merge it. |
I'm in full agreement of this, let me know if you approve the idea of merging this PR, then I'll address the feedback from Min and rebase this etc for a merge! |
This was discussed in today's JupyterHub team meeting. We agreed to go ahead with this, and merge in two weeks time (2022-03-03)! |
cafcd18
to
e2295ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
When you run pre-commit can you add a .git-blame-ignore-revs
too? It's feature in Git that GitHub now supports, and should mean the repo-wide auto-formatting commits are skipped in the blame view:
jupyterhub/binderhub#1381 Merge pull request #1381 from consideRatio/pr/pre-commit
Woohoo for closing 6 months old PRs! |
UPDATED PR STATUS: Awaiting resolution of #1390
I think there is no easy way of getting this done initially, but I figured I'll make a go for it. WDYT?
I opted to not apply prettier on js/html/css at this point as it became less readable code when only two spaces was enforced. We can run prettier twice with different settings for html/css/js vs markdown/yaml/json etc if we want to handle that in the future - of which I made a comment about.
Related
Action points
Remove weird executable flags on files #1384
Remove unused imports #1385
Fix various flake8 warnings #1386
Use f-strings where pyupgrade doesn't handle it automatically #1387
Formatting adjustments to make the code transform nicer with black autoformatting #1388
Remove whitespace for flake8 #1389
Discussion on how in Add pre-commit: pretter, black, pyupgrade, and misc #1381 (comment)
A dedicated issue to handle the situation: Give attention to and triage in our pull request list #1390