Skip to content

Add optional .pre-commit-config.yaml for the OpenFermion project#1289

Merged
mhucka merged 39 commits intomainfrom
pre-commit
Apr 29, 2026
Merged

Add optional .pre-commit-config.yaml for the OpenFermion project#1289
mhucka merged 39 commits intomainfrom
pre-commit

Conversation

@mhucka
Copy link
Copy Markdown
Contributor

@mhucka mhucka commented Apr 27, 2026

This adds a .pre-commit-config.yaml based on what I have been using for some time. Nothing invokes the pre-commit hooks directly, and it is up to the user to configure it and use it if they wish. The intention is to provide a modest pre-commit configuration that can help people avoid some common mistakes.

pre-commit is a framework for managing and maintaining git hooks. It's an open-source project and has extensive documentation. It's a way for devs to run checks on their code locally before they commit or push it.

@mhucka mhucka marked this pull request as ready for review April 27, 2026 20:03
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a .pre-commit-config.yaml file to the OpenFermion project, configuring a comprehensive suite of hooks for linting, formatting, and security checks. The review feedback identifies several necessary corrections: fixing a regex syntax error in a local hook's file matching pattern, correcting a version mismatch in the isort hook comment, replacing a non-portable absolute path for the copyright notice template with a relative one, and removing irrelevant, non-existent paths from the exclusion list.

Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Copy link
Copy Markdown
Contributor

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

I don't have experience with the pre-commit tool. It may be worthwhile to test this for a stock Ubuntu account without any of your local customizations. I mean, if users set up their development environment for OpenFermion and activate the pre-commit hooks, will they work out of the box?

podman run --rm -ti ubuntu:noble bash

Otherwise LGTM.

@mhucka mhucka added the area/devops Involves build systems, Make files, Bazel files, continuous integration, and or other DevOps topics label Apr 27, 2026
mhucka added 6 commits April 28, 2026 03:07
We currently don't use isort in this project.
The problem is that it flags typos in parts of a file that you didn't
touch. If you fix those, you pollute your PR with unrelated changes.
@mhucka mhucka changed the title Add initial .pre-commit-config.yaml for the OpenFermion project Add a .pre-commit-config.yaml for the OpenFermion project Apr 28, 2026
@mhucka mhucka changed the title Add a .pre-commit-config.yaml for the OpenFermion project Add optional .pre-commit-config.yaml for the OpenFermion project Apr 28, 2026
mhucka added 11 commits April 28, 2026 21:47
- id: check-github-issue-config
- id: check-github-issue-forms
Rarely relevant because the config file changes so infrequently, plus
it's extremely unlikely that a non-core contributor would edit those
files.
I'm not even sure what the threshold is.
We have other tools on GitHub that look for those things.
This causes more problems than it's worth.
@mhucka
Copy link
Copy Markdown
Contributor Author

mhucka commented Apr 28, 2026

if users set up their development environment for OpenFermion and activate the pre-commit hooks, will they work out of the box?

podman run --rm -ti ubuntu:noble bash

A good question. It's a bit difficult to test doing an actual git commit, but I did the following inside a docker environment:

python3 -m venv venv
source venv/bin/activate
pip install pre-commit
pre-commit install -t pre-commit -t commit-msg -t pre-push
pre-commit run

And this works. So, I think it's reasonable to believe it will work for other people.

mhucka added 2 commits April 29, 2026 01:17
This doesn't seem to appear in the code base anyway. Let's save a bit of
time time by skipping it.
With a little help from my friend, Gemini.
@mhucka mhucka enabled auto-merge April 29, 2026 01:31
@mhucka mhucka added this pull request to the merge queue Apr 29, 2026
Merged via the queue into main with commit 97d925a Apr 29, 2026
19 checks passed
@mhucka mhucka deleted the pre-commit branch April 29, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/devops Involves build systems, Make files, Bazel files, continuous integration, and or other DevOps topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants