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
Standardized formatting with pre-commit (plan) #816
Comments
Haven't had time to look in detail yet, but it looks like some bits of shed do Python version detection. How can that possibly work? We want to match the version of Python that ships with talon public, which may not match any Python version installed on a dev's machine (even the one Talon uses if beta and public are on different versions). |
Shed supports passing flags such as But yeah, the user should probably install a matching version of Python -- I'll add that to the instructions. |
My understanding is that it mostly leans on |
We might want to use |
Ah, great suggestion, thanks @pokey! Also, just checked, looks like Talon Public uses Python 3.9.5, so we should be fine assuming 3.9 everywhere |
pyupgrade does this too, but is conservative when facing ambiguity with %-formatting, specifically with a single %s and a bare variable RHS, IIUC. How many cases of these do we have (and would we expect to have in future contributions)? |
I'll check! |
Status update:
Merging in your forksThe reformatting will likely create some merge conflicts in your forks. You can reduce the number by using the following $ git merge -Xignore-all-space upstream/master (Relatedly, imerge is also a very useful tool for merging your fork incrementally, both @pokey and I have used it and can recommend it) Please comment here if you find any other issues. Conflict resolution offerLastly, I understand that these merged conflicts might be painful. To help speed the process and reduce pain, I'm making a standing offer to resolve the merge conflicts caused by auto formatting in your forks for you, if you would like. The only caveats are that you need to give me access to your fork if it's private, and you also have to be merged up to the commit just before we introduced auto formatting (this offer only applies to the auto formatting itself :)) If you're interested, just reach out to me over Slack. |
As far as moving on to the more aggressive formatters in phase 2/3, I think we want to wait a week or two to let the dust settle and see if any issues arise from people. If there are no problems, we proceed as planned :) |
So shall we go ahead with phase 3 then? |
Fwiw I just did an imerge to incorporate these formatting changes. I didn't use the Every time imerge presented me with a commit that conflicted with 2877a68, I would do the following:
This seemed to work well |
Also, we may want to steal the setup from a personal project that I have. I based it off the Cursorless version, which went through fairly strenuous review, but had some fairly Cursorless-specific stuff in it. Here's the two files I think we could just steal verbatim: |
Thanks @pokey! The only change I made was to set the |
Fwiw I created a gist showing how I did my merge https://gist.github.com/pokey/748ba17a2b7ee88c884992e477632ebb |
This is a proposal for how to go about implementing #666. The thought here is to move incrementally to give everybody time to adapt to the new contribution flow, resolve conflicts with their branches, and/or identify problems caused by the reformatters.
I propose doing this in three phases, waiting a week or two in between each one:
Phase 1: Basic rules + CI enforcement
PR: #817
.pre-commit-config.yaml
with the most common/unobjectionable rules (standardizing trailing whitespace, consistent line endings, enforcing newline at the end of files, detecting unresolved merged conflict markers, etc.)pre-commit
.pre-commit run --all-files
onmaster
to apply all the fixes immediately tomaster
and push them up.master
to require a green pre-commit check for PRs.Phase 2: Incremental parts of
shed
shed
is a "super all in one" reformatter+fixer for Python code, including the aggressive/opinionatedblack
reformatter. It has the advantage of configuring these tools to work well together. Thanks to @auscompgeek for the recommendation.In this phase, we add the "cleanup" parts of
shed
, but omit the massive reformatting of Black for now:We'll also add prettier to reformat Markdown files -- this is optional if we want to cut down on the number of formatters, but nice to have.
As with the first step, we wait a little bit for the dust to settle and for problems to arise / merged conflicts to be resolved, etc.
Phase 3: Full Shed/Black
Finally, in this phase we apply
shed
in its entirety, which includesblack
. We can remove the individual utilities added in Phase 2 (exceptflynt
), since shed includes them. We can set the--refactor, --py39-plus
flags here now or do this as a final fourth phase.Discussion
If people don't really think the phase 2/3 split is warranted, I'm happy to just combine them.
The text was updated successfully, but these errors were encountered: