Skip to content
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

Enable pre-commit.ci autofixes #181

Merged
merged 5 commits into from
Dec 19, 2023
Merged

Enable pre-commit.ci autofixes #181

merged 5 commits into from
Dec 19, 2023

Conversation

antonymilne
Copy link
Contributor

@antonymilne antonymilne commented Nov 24, 2023

Description

This PR enables automatic linting fixes using pre-commit CI. Please watch the team learning session for a full introduction.

I have left autofix_prs enabled for now because I think it's the best option to try out. If we find it a nuisance then we can switch to a different workflow where you need to manually comment pre-commit.ci autofix in order to trigger the linting fix.

What this means is that pre-commit CI will automatically make linting fix commits on your branch, and if you try to push on top of that you will get a failure from git "Updates were rejected because the remote contains work that you do not have locally". If you use PyCharm then a window will pop up:
image
The recommended strategy is "Rebase". Tick "Remember ..." if In future you don't want to be prompted again (also recommended).

If the window didn't pop up or you clicked the wrong button or something then you can also specify this in your PyCharm settings:
Screenshot 2023-11-24 at 12 47 13 pm

If you do git from command line then I recommend setting

git config pull.rebase true
git config rebase.autoStash true

You could also set an alias for git pp to do "pull and then push":

git config alias.pp '!git pull && git push'

Checklist

  • I have not referenced individuals, products or companies in any commits, directly or indirectly
  • I have not added data or restricted code in any commits, directly or indirectly
  • I have updated the docstring of any public function/class/model changed
  • I have added tests to cover my changes (if applicable)

Types of changes

  • Docs/refactoring (non-breaking change which improves codebase)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

@antonymilne
Copy link
Contributor Author

Also FYI @AnnMarieW (I still couldn't add you as reviewer here so will check the settings again). The intention of this is to make the contribution process smoother so that you don't even need to run hatch run lint - instead the fixes should be applied automatically in your PR.

Copy link
Contributor

@huong-li-nguyen huong-li-nguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Contributor

@petar-qb petar-qb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to have this one 😄.

@antonymilne antonymilne enabled auto-merge (squash) December 19, 2023 13:28
@antonymilne antonymilne merged commit 258d58a into main Dec 19, 2023
37 checks passed
@antonymilne antonymilne deleted the ci/pre-commit branch December 19, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants