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

Add pre-commit and run auto-formatters #699

Merged
merged 3 commits into from
Apr 7, 2022
Merged

Conversation

blink1073
Copy link
Member

This should be merged as a merge commit so git-blame-ignore-revs works.

@blink1073
Copy link
Member Author

Downstream test failure is unrelated

@blink1073 blink1073 requested review from minrk and Carreau April 7, 2022 08:47
@Carreau
Copy link
Member

Carreau commented Apr 7, 2022 via email

@blink1073 blink1073 merged commit b0c30ce into ipython:main Apr 7, 2022
@blink1073 blink1073 deleted the pre-commit branch April 7, 2022 16:12
Copy link
Contributor

@rmorshea rmorshea left a comment

Choose a reason for hiding this comment

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

Could you update the development installation instructions to explain how to set up pre-commit?

I've also found that people can sometimes find pre-commit frustrating when hooks cannot automatically fix the issues they discover. For example, black works great as a pre-commit step for most people because it automatically fixes any stylistic mistakes, but flake8 can be annoying because it reports the error without fixing it and will block you from committing until you fix everything it's complaining about. If the commit is really just a WIP and you don't want to fix everything right then and there, you have to know to go look at the pre-commit docs and figure out how to turn off its checks for that commit.

Pre-commit checks like flake8 are fine to run in CI, but maybe not by default on ever commit a developer might make as they're writing code. Given this, it looks like pre-commit allows you to configure when hooks will run using stages. Perhaps for those hooks which do not automatically correct mistakes they could be marked as manual and only run in CI.

Comment on lines +34 to +37
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.942
# hooks:
# - id: mypy
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be removed

Copy link
Member Author

Choose a reason for hiding this comment

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

I am adding this in a follow up PR as well

@rmorshea
Copy link
Contributor

rmorshea commented Apr 7, 2022

Shoot, didn't see this was already merged. Maybe these minor nits could be done in a follow up?

@blink1073
Copy link
Member Author

I'll follow up with docs and moving some of the checks to ci-only by using the manual stage.

@rmorshea
Copy link
Contributor

rmorshea commented Apr 7, 2022

Awesome!

@blink1073
Copy link
Member Author

Great feedback by the way @rmorshea, I'll use that approach across repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants